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

Python

The document outlines the features and modes of Python, emphasizing its ease of use, dynamic typing, and extensive libraries. It details various data types, methods for manipulating lists, tuples, and sets, as well as operators and control flow structures like conditional statements and loops. Additionally, it explains the concept of functions and types of arguments in Python programming.

Uploaded by

bivora7467
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python

The document outlines the features and modes of Python, emphasizing its ease of use, dynamic typing, and extensive libraries. It details various data types, methods for manipulating lists, tuples, and sets, as well as operators and control flow structures like conditional statements and loops. Additionally, it explains the concept of functions and types of arguments in Python programming.

Uploaded by

bivora7467
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Features of Python-

1. easy to learn and use


2. interpreted lang
3. dynamically typed – no need to specify declare variables
4. extensive libraries and modules
5. OOPs concept support class and object-based prog
6. platform independent- supported on all OS
7. used in real world appli. – used in AI, ML used in tesla, web development, data analysis, automation
python –version for checking python lang installed version.
Modes of python-
Script mode- directly a file is executed. When executing in vs code it is script mode (enter to change line in code)
Interactive mode- we execute each and every line. when executing in cmd(Python shell) interactive mode.(enter to directly execute the code)
Variables:- it is fixed memory location to store data/value.
Print(“Number one”,num1) statement and argument assigned
type()- is class to find datatype of variable
input()- to take value from user, by default data is in string

Datatypes:- it is collection of various datatypes, describes what type of data we are storing in variable.
1.Numerical- int, float, complex(imaginary no. – 5j)
2.Sequential - collection of elements stored in variable-
list (collection of elements enclosed in [ separated with , ]) duplicate values allowed, mixed datatypes allowed, It is mutable it can be changed
string collection of characters enclosed in ‘ ‘,“ ”,’ ‘ ‘(multiline) , it is immutable cannot be changed
tuple in (,)- collection of datatypes enclosed in separated by (,). It is immutable used when data is not going to change (if want to change data convert it to list)

3.Set - collection of unordered elements inside {,}, allows mixed elements, doesn’t allows duplicates, immutable, do not have fixed memory allocation
4.Dictionary (collection of elements inside {,} but in key value pair, accessing elements through what the key is assigned, mutable(allows editing outside the OG indexing),
duplicates- values can be allowed to be same but keys must be not same
5.Boolean – (o/p in form of true or false)

For adding list, we have three methods.


1. append - only one element (argument) can be inserted in list at end
2. insert- at a particular index we can insert takes two arguments 1st posn 2nd element which u wanna insert
3. extend- add another list as argument element in the list
sort()- sorting data in ascending descending order
index()- finding the elements in list, two arguments passe 1st element to be searched 2nd after what posn
For clearing deleting elements in given list
clear()- totally clears entire list
pop()- removes element based on index no.
remove()- removes element by its name/value

Tuple methods –
count()-counts the occurrence of elements how many times it has written
index()- count at what posn the element Is located, two argument first which element second after what u want to search

Set Methods-
add()- we can add new elements in existing set
update()- we can join or update two or more sets means concatenate

Operators – these are the special symbols which perform operations on values or variables
There are 7 types of operators
1.Arithmetic (+ , - , * , / , // , ** ,%)
Division (/) - it will give floating point number Quotient as output
Floor division (//) – it will give the integer part of Quotient as output
Exponential (**) – it will give exponential value of a number
Modulus (%) - it will give remainder give as output

2. Relational – mostly used for comparison (==, <=, >=, <, >, !=)
3. Logical (and, or, not)
4. Bitwise
5. Assignment (=, +=, -=, *=, /=)
6. Membership – used to check whether the value taken is present in sequence or not (in, not in)
7. Identity- it compares the memory location/address of both object (is, is not)
Conditional statements – it is a statement which helps to execute a block of code based on condition applied.
Indentation space place vital role in conditional statements, that is space after certain conditional statement
1. if statement-
2. if else
3. if elif else
4. nested if else

Looping - Repeatedly execution of a set of code until a condition is satisfied.


1.for loop- It iterates a particular sequence
Syntax:
For element in range():
print()
range()- gives sequence of data of no.s betn provided numbers/range three parameters (start, end, step)

2.while loop- It executes set of code multiple times till the condition satisfies
Syntax:
initialization/Start
while(condition):
#block of code
increment/decrement
Function- It is a block od code which performs a particular task,and is executed only when it is called. Initial letter compulsory capital.
Syntax:
Def function_name():
#block of code
return expression/value/variable

#function call
function_name

pass keyword- it allows to keep the function empty. The pass statement is used as a placeholder for future code.

Types of Arguments:-
1.Positional Arguments- Order must be followed by argument as per the parameters
2.Keyword Argument- Assigning parameter and argument like key and value pairs. In any order
3.Default Argument- In it directly parameters are assigned with values (compulsory it must be assigned at the end)
4.Variable length-
*args(arguments)- it is returns value in tuple
**kwargs(keyword arguments)- returns value in dictionary

You might also like