* pythone *
- pythone is high interpreted language that is usd to develop software and
web applications
- python is a set of instructions
python devlop by guido van roosum in 1980. the first version relesd in 1991 that
includes class,list and string
* interpreter : inter- is translate py code to machine code so that computer can
understand It excute line by line code
* pythone structure :
1. documentaion section // it inclueds comments
2. import statement // it include user define modules
3. global declartion section // global variable
declartion
4. class section // it's collection of data mebers and
meber function called method
5. subprogram section
// this is essential section
6. play ground secttion is imp
* data types in python
// set & dictonary are unorder
1. number
2. string // immutable
3. list // mutable // represent sequential data //it's like array ex. a
= [10,30,'hi']
4. tuple // immutable // Similar to lists but immutable, meaning their
contents cannot be changed after creation
ex. a= ('manoj',30,'hi')
5. dictionary // An unordered collection of key-value pairs
ex. student = {
"name": "John",
"age": 21,
"grades": [88, 92, 85]
}
6. boolean
7. non // It is often used to indicate that a variable does not yet hold
any value.x
8. set // An unordered collection of unique items. Sets are mutable but
cannot contain duplicate elements.
ex. unique_numbers = {1, 2, 3, 4, 5}
* Sring :
-it is a collection of chracter and strings are immutable
-we can use string in multiple lines using triple code ( """ """ )
opertaions
1. string slice : a = "abhi" // a[1:5]
2. upper() & lower()
3. strip() // for removing wigth space
4. F-Strings // age = 36
txt = f"My name is John, I am {age}"
5. index("// value of steing ")
* list :
1. insert : // insert a specified index // ex. a.insert(2,"abhi")
2. append : // insert in last element // ex . a.append("manoj")
3. extend : // merging two lists
ex . a,b= [10,20],[30,40] a.extend(b)
4. clear() : clear all the elements
5. sort(), pop(''// pop specified indexb elemewnts'), index()
6. remove("// sertan elements")
* tuple
- tuple is order collection and unchangeble
- we can not change a tuple after creation. it's immutable
- it's faster than list and safe the data bec-s immutable
operatioons:
1. accesing tuple // tup[0]
2. concatination
3. updating // tup[0]="abhi"
4. deleting tup // del tup
* dectionary
- it's unorder collection and mutable
- they have a key and values pairs
operation:
1. accesing // dect[ // key to access]
2. updating // dic[ // key] = "// value" and we can insert value like
this
- values() : // accesing only value
- item(): // key and value both are accsee
3. deleting :
- del // dect["name"] // delete one entry
- dect.clear() // clear all entrys
- del dect // deleting entire dectionry
4. pop() :
5. dectionary function() : // cmp // len // str / type
* funtion :
- func- is a block of code
- two types of function
1. build in 2. userdefind
syntax : def funk1(par1, par2):
- calling function
- anonymus // are also called lambda function // does not have any name //
it defines lambda
* modules and packages *
* modules
- reusable code
- modules are .py extension that conatin python programing conatin like
function,class, varibles
prdifined modules : math & cmath, decimal, fractional, statical, time(),
datetime(), random()
* packages :
- packges is collection of modules
- packages is collection of python modules
* class,object and inheritance *
- python is object orienteted lanuage this mean all the code is implementd a
using special constructor called class.
- object is instance of class and class is collection of objects and data
meber, member function.
- class is user defind data type
* inheritance :
- when we use other class properties in one class are called
inheritance.
types of inheritance :
1. single inhe- have only one parent class and chaild class
2. multiple inhe- have two parent class and one chaild class
3. multilevel inhe- in this case we have one parent class and multiple
child class.
4. hybrid inher- combination of more than one inheritance
5. hierachical inheri- tis inheritnce contain one parrent class and
multiple chiled class but each child class can access
parent class property .
* Exception handaling *
- exception handaling is also known as run time error.
- exception is an event which is occurs during the execution of a program
exception handaling using try - except - else
keywords : rised and finaly
three types of error
1. compile time
2. run time
3. logical error
* GUI programing *
- garphical user interface is an intractive environmenet
- tikinter
imp question in practicle
1. check whether a input number is Armstrong number or not.
2. check whether a input number is perfect number of not.
3. check whether a input number is palindrome or not.