0% found this document useful (0 votes)
98 views

Python Lecture 1 Notes

Python can be used for data analysis, artificial intelligence, machine learning, web development, and scientific computing. It is easy to learn, free and open source, portable across platforms, and has a large library. Python code is interpreted line by line and supports object-oriented programming with classes and objects. Variables store values and have different data types. Functions allow code reuse and decomposition to solve problems. Collections like lists, dictionaries, tuples and sets store multiple values. Exceptions handle errors and disruptions to normal program flow.

Uploaded by

Shreya Nair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views

Python Lecture 1 Notes

Python can be used for data analysis, artificial intelligence, machine learning, web development, and scientific computing. It is easy to learn, free and open source, portable across platforms, and has a large library. Python code is interpreted line by line and supports object-oriented programming with classes and objects. Variables store values and have different data types. Functions allow code reuse and decomposition to solve problems. Collections like lists, dictionaries, tuples and sets store multiple values. Exceptions handle errors and disruptions to normal program flow.

Uploaded by

Shreya Nair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

PYTHON LECTURE 1 NOTES

WHY PYTHON?

 Perform data analysis.


 Build artificial intelligence
 Machine learning (Giving computer the ability to learn)
 Web and internet development
 Python enterprise business application
 Perform scientific computing

FEATURES OF PYTHON

 Easy: Python is very easy to learn and understand.


 Free and open source: The language and Its source code are free of cost.
 Portable: You can run python on Windows, Linux, Mac or any other platform.
 Large library: Python provides you with a large and standard library. You can use it to implement
a variety of functions.
 Interpreted: It is interpreted or executed line by line.
 Object-oriented: It supports classes and objects.

VARIABLES

Variables are reserved memory locations to save values. So, when the variable is created, depending
upon the type of variable, memory is allotted to store the value.

Different data types of variables are: int, float, string, etc.

 A variable name must start with a letter or the underscore character


 A variable name cannot start with number.
 Variable names are case sensitive (Ex: “price” and “Price” are two different variables)

GLOBAL AND LOCAL VARIABLES

Global Variables:

 Declared outside the function.


 Can be accessed in any function in the program.

Local Variables:

 Declared inside a function.


 Can be used only inside that function.
 It is possible to have local variables with same name in different functions.
DIFFERENT COLLECTION OBJECTS

LIST

 A list is a data structure in python that is mutable, ordered sequence of elements.


 Python list is a heterogenous collection of items.
 Lists are written with square brackets.

DICTONARY

 Python dictionary is an unordered collection of items.


 Dictionary has a key: value pair.
 It is written with curly brackets.

TUPLE

 A tuple is a collection which is ordered and immutable.


 It is written with round brackets.

SET

 Returns unique instance of any value (No duplicate)


 Set is unordered so it doesn’t support indexing.

FUNCTIONS:

A function is a group of statements that are executed whenever that function is called to perform a
specific task.

Advantages of function:

1. Reuse of code which reduces duplication of code.


2. Decomposing complex solution in smaller units
3. Helps in better maintenance
4. Easily can be accessed across classes, modules, etc.

EXCEPTION HANDLING

An exception is an event, which occurs during the execution of a program that disrupts the normal flow
of the program’s instructions. In general, when a python script encounters a situation that it cannot
cope with it, it raises an exception.

You might also like