Python
---
high level prog language
Guido Van rossam
1991
#include<stdio.h>
void main
{
int a,b;
printf("hello world");
}
we can use python
[Link] web appli
[Link] appln
[Link] appln
network prog
data analysis
machine learning
AI
IOT
[Link] and easy
30 keywords
[Link], opensource
Jython
cython
Ruby python
[Link] independent PVM
[Link] typed
[Link] procedure and OOP
[Link] intepreter
Anaconda python- tp process huge volume of data
1994 python 1.0
python 3.8
a=10
identifiers should start with alpahsbet
digits are allowed, _ is also allowed
$-not allowed
abc=10
ABC=10
python is case sesitive
_ it is a private
__ strongly private
keywords
30+ keywords are avaialble
Data types
-------------
Int
float
boolean
str
bytes
complex
range
bytearray
list
tuple
set
dict
None
frozenset
type()- to check type of variable
id() to get address of object
operators
--------
sepcial opr
[Link] opr(is/is not)- used for address comparison
[Link] opr(in/not in)
to check given object is present in given collection(string,set,tuple,list dict)
== is for content comparison
substring
---------
4 methods
forward-- find(),index()-- [Link](substring)//returns first occurrence of the given
substring,-1 if it not avaiable
backward-- rfind(),rindex()
------------------------------
# -*- coding: utf-8 -*-
"""
Created on Mon May 3 [Link] 2021
@author: Poorni
"""
#
#print("hello world")
#a=10
#b=30
#print("the sum",(a+b))
#print(type(a))
#a=3+5j
#print(type(a))
#a=True
#print(type(a))
#
#import keyword
#print([Link])
#a="""learning
#python
#is
#very
#simple"""
#
#print(type(a))
#a=[10,20,30,40]
#b=bytes(a)
#print(type(a))
#print(type(b))
#print(b[2])
#range data type represets some sequence of numbers
#range type is immutable
#r=range(10)
#for i in r:
# print(i)
#r=range(10,20)
#for i in r:
# print(i)
#r=range(10,20,2)
#for i in r:
# print(i)
#a=100
#b=20
#print("a>b", a>b)
#a=10
#b=30
#print(a is b)
#s="learing python is very simple"
#print("z" in s)
#
#x=input("enter the value")
#print(type(x))
#s="poornamathi"
#s1="""poorna
#mathi
#is a
#good
#girl"""
#s1='a'
#print(type(s1))
#s="helloworld"
#print(s[-4])
#[0] left to right
#[-1] right to left
#print(int(123.456))
#print(float(10))
#a=10
#b=20
#c=a<b
#print(c)
#print(type(a))
#s='poorna'
#s1="""learning
#python
#is
#very simple"""
#print(s1)
#x=[10,20,30,40]
#b=bytes(x)
#print(type(b))
#print(b)
#identity operator
#a=10
#b=10
#a==b content comaprison
#print(a is not b)
#membership operator in not in
#a="hello learning python is very easy"
#print('h' in a)
#
#
#ch='a'
#print(type(ch))
#a=10+1.5j
#b=20+1.2j
#c=a+b
#print(c)
#print(type(c))
#b=20
#print("the sum is",(a+b))
#s="poornamathi"
#s='poornamathi'
#representing multline string literals
#s="""learning
#python
#is
#very simple"""
#x=input("enter the value")
#print(x)
#
#for x in sequence
#s="poorna mathi"
#for x in s:
# print(x)
#
#for x in range(11):
# if(x%2!=0):
# print(x)
#for x in range(10,0,-1):
# print(x)
#x=1
#while x<=10:
# print(x)
# x=x+1
#name=input("enter name")
#if name=="poorna":
# print("hello poorna")
#else:
# print("hello guest")
#String
#slicing technique []
#s='a'
#s="poornamathi"
#print(s[4])
#print(s[-4])
#print(s[20])
#s="Learning python is very very easy"
##s[beginindex:endindex:step]
#print(s[Link])
#print(s[1:7])
#print(s[1])
#print(s[:7])
#print(s[7:])
#print(s[::])
#print(s[::-1])
# +(concatenation),compulsory both arg should be str type
# *(repition operator) compulsory one arg should be str and other arg should be
int type
#
#print("poorna"+"mathi")
#print("poorna"*2)
#s="Learning python is very very easy"
#print(len(s))
#print([Link]("python",0,10))
#print([Link]("poorna"))
#s="Learning python is very very easy"
#s1=[Link]("very","simple")
#print(s1)
#print([Link]())
#print([Link]())
#print([Link]())
#print([Link]())
#print([Link]())
#print([Link]())
#l=[Link]()
#for x in l:
# print(x)
#s="Learning python is very very easy"
##print(s[Link])
#print(s[7:])
#print(s[:7])
#print(s[::])
#print(s[:])
#print(s[::-1])
#print("poorna"+"mathi")-concatination operator
#print("poorna"*2)-- repetation operator
#len()
#s="poornamathi"
#print(len(s))
#membership operator "in/not in", to check string is the member of another string
#s="poornamathi"
#print('d' in s)
#print('a' in s)
#comparison .<,>,<=,>=,==,!=
#substring using index and find method
#s="Learning python is very very easy"
#print([Link]("z"))
#
#print([Link]("z"))
#count
#s="abcabcbabcbacbac"
#print([Link]('a'))
#print([Link]('a',3,7))
#replace,[Link](oldstring,newstring)
#s="Learning python is very very simple"
#s1=[Link]("simple","difficult")
#print(s1)
#isalnum(),islower(),isupper(),isspace(),isdigit()
#ch='a'
#print(type(ch))
#
#x=input("enter the value")
#if x=="poorna":
# print("HEllo poorna")
#elif x=="mathi":
# print("hello mathi")
#else:
# print("hello guest")
#s="poorna mathi"
#for x in s:
# print(x)
#
#s=input("enter string")
#i=0
#for x in s:
# print("the character present at",i,"index is",x)
# i=i+1
#
#for x in range(11):
# print(x)
#for x in range(21):
# if(x%2!=0):
# print(x)
#for x in range(10,0,-1):
# print(x)
#x=1
#while x<=10:
# print(x)
# x=x+1
#s="poorna"
#s='poorna'
#ch='a'
#type(ch)
#s="learning python is very simple"
#l=[Link]()
#for x in l:
# print(x)
#
#list=[input("enter the list")]
#print(list)
#print(type(list))
#s="Learning Python is very very easy!!!"
#print(s[Link])
#s=input("Enter Some String:")
#i=0
#for x in s:
# print("The character present at positive index {} and at nEgative index {} is
{}".format(i,i
#-len(s),x))
# i=i+1
#s=input("Enter main string:")
#subs=input("Enter sub string:")
#if subs in s:
# print(subs,"is found in main string")
#else:
# print(subs,"is not found in main string")
# s="abcabcabcabcadda"
# print([Link]('a'))
# print([Link]('ab'))
# print([Link]('a',3,7))
#
#s="ababababababab"
#s1=[Link]("a","b")
#print(s1)
List
----------
represent a group of elements as a single entity
insertion order is preserved // 1 4 6 7
duplicate elements are allowed, differentiated by using index
hetegrogenous elements are allowed
list is dynamic, increase/decrese the size of the list
[]
mutable
# -*- coding: utf-8 -*-
"""
Created on Tue May 4 [Link] 2021
@author: Poorni
"""
#empty list
#a=[]
#print(a)
#print(type(a))
#list=[1,2,3,4,5,'poorna',6.7,'mathi']
#print(list)
#l=list(range(0,10,2))
#print(l)
#
#n=[1,2,3,4,5,6,7,8,9]
#print(n[4::2])
#print(n[Link]-2])
#print(n[4:100])
#
#n=[10,20,30,40]
#print(n)
#n[1]=70
#print(n)
#
#n=[0,1,2,3,4,5,6,7,8,9,10]
#i=0
#while i<len(n):
# print(n[i])
# i=i+1
#for n1 in n:
# print(n1)
#n=[0,1,2,3,4,5,6,7,8,9,10]
#print(len(n))
##
#count returns the no of occurences of items in the list
#n=[1,2,2,2,2,3,3,4]
#print([Link](2))
#index returns the first occurence of the specif item
#
#n=[1,2,2,2,2,3,3,4]
#print([Link](2))
#append()//to add an element at the end of the list
#
#list=[]
#[Link]("a")
#[Link]("b")
#[Link]("c")
#print(list)
#insert()- to insert item at specified index position
#n=[1,2,3,4,5]
#[Link](1,88)
#print(n)
#append-when we add an element it will come in the last position
#insert()- we can insert any element at particular index number
#n=[1,2,3,4,5]
#print(n)
#[Link](-5,6)
#[Link](10,6)
#extend- to add all itemns of one list to another list
#[Link](l2)
#
#l1=["a","b","c"]
#l2=["d","e","f"]
#[Link](l2)
#print(l1)
#print(l2)
#remove()- remove specific items from the list.
#if items are present
#multiple times first occurence will be removed
#n=[10,20,30,10]
#[Link](10)
#print(n)
#n=[10,20,30,10]
#[Link](30)
#print(n)
#pop()- removes and returns the last element of the list
#n=[10,20,30,40]
#print([Link]())
#print([Link]())
#print(n)
#n=[]
#print([Link]())
#n=[10,20,30,40]
##print([Link](1))
#print([Link](10))
#
#append(),insert(),extend()- for increse the size of the list
#remove(),pop()- to decrese the size of the list
#n=[10,20,30,40]
#[Link]()
#print(n)
#
#n=[70,40,50,40]
#[Link]()
#print(n)
#copy()
#x=[10,20,30,40]
#y=[Link]()
#y[1]=70
#print(x)
#print(y)
#concat operator '+'
#a=[1,2,3,4]
#b=[4,6,7]
#c=a+b
#print(c)
#n=[10,20,30,40]
#y=n*3
#print(y)
#n=[10,20,30,40,[50,60]]
#print(n)
#print(n[0])
#print(n[3])
#print(n[4][0])
#print(n[4][1])
#membership operator(in/not in)
#-----
#n=[10,20,30,40]
#print(40 in n)
#list comprehension
#list=[expression for item in list if condition]
#s=[x*x for x in range(1,11)]
#print(s)
#s=(x for x in s if x%2==0)
#print (s)
tuple
-------
immutable
tuple is read only version of list
insertion order is preserved
duplicate elements are allowed, differentiated by using index
hetegrogenous elements are allowed
()
# -*- coding: utf-8 -*-
"""
Created on Tue May 4 [Link] 2021
@author: Poorni
"""
#Tuple datastructure
#t=10,20,30,40
#print(t)
#print(type(t))
#t=(10)
#print(type(t))
#single valued tuple
#t=(10,)
#print(type(t))
#t=(10,20,30,40)
#t[1]=90
#a=[startvalue:endvalue:skipvalue]
#t=10,20,30,40,50,60
#print(t[2:5])
#print(t[2:100])
#print(t[-1])
#list=[10,20,30,40]
#t=tuple(list)
#print(t)
#print(type(t))
#concatenation , reitition opr
#t1=(10,20,30)
#t2=(40,50,60)
#t3=t1+t2
##t3=t1*3
#print(t3)
#len()
#t1=(10,20,30,40)
#print(len(t1))
##
#t=(10,20,30,10,20)
#print([Link](10))
#sorted(),max(),min(),index(),count
#cmp() avaibale in python 3
#0-both tuple are equal
# -1 then first tuple is less than the second tuple
# +1 then first tuple is greater than second tuple
#t1=(1,2,3,)
#t2=(5,6,7)
#t3=(1,2,3)
#print(cmp(t1,t2))
#print(cmp(t1,t2))
#tuple packing
#a=10
#b=20
#c=30
#d=40
#t=a,b,c,d
#print(t)
#print(type(t))
#tuple unpacking
#t=(10,20,30,40)
#a,b,c,d=t
#print("a=",a,"b=",b,"c=",c,"d=",d)
#Tuple comprehension
#
#t=(x**5 for x in range(1,6))
#print(type(t))
#for x in t:
# print(x)
set
----
unique elements
insertion order is not preserved but we can perform sorting
6 1 2 5 3 4
no indexing and slicing
heterogeneous elements
mutable
{ }
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 27 [Link] 2021
@author: Poorni
"""
#s=set(any sequence)
#s={10,20,30,40}
#print(s)
#print(type(s))
#s=set(any sequence)//list,tuple
#l=[10,20,30,40,50]
#s=set(l)
#print(s)
#print(type(s))
#s=set(range(5))
#print(s)
#t=(10,)
#print(type(t))
#s={}
#print(type(s))
#s=set()
#print(type(s))
#s={10,20,30,40}
#[Link](50)
#print(s)
#s={10,20,30}
#l=[11,21,31,41,51]
#[Link](l,range(5))
#print(s)
#[Link](8,9,10)
#[Link](70)
#s1=[Link]()
#print(s1)
#
#s={10,20,30,40}
#print([Link]())
##print([Link])
#print(s)
#[Link](30)
#[Link](10)
#
#[Link]()
#union returns all elements present in both sets
#x={10,20,30,40}
#y={30,40,50,60}
#
#s=[Link](y)
#s1=x|y
#print(s)
#print(s1)
#intersection returns common elements present in x and y
#print([Link](y))
#difference returns elements present in x not in y
#print([Link](y))
#print(x-y)
#print(y-x)
#symmetic difference reutns elements present in
#either x or y but not in both
#print(x^y)
#
#s=set("poorna")
#print('p' in s)
#
#
#s={x*x for x in range(5)}
#print(s)
#
#
#print(s[0])
Dict
------
key-value pair
duplicate keys are not allowed but values can be duplicated
insertion order is not preserved
dict are mutable
no indexing and slicing
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 27 [Link] 2021
@author: Poorni
"""
#duplicate keys are not allowed but values can be duplicated
#heterogeneous elements are allowed
#insertion order is not preserved
#dict are mutable
#no index and slicing
#d={}
#print(type(d))#D={}
#d=dict()
#d={100:"poorna",200:"mathi",300:"maanav"}
##print(d[100])
#print(d[400])
#d={100:"poorna",200:"mathi",300:"maanav"}
#if 200 in d:
# print(d[200])
#update dict
#d[key]=value
#d={100:"poorna",200:"mathi",300:"maanav"}
#print(d)
#d[400]="prabu"
#d[100]="poo"
#print(d)
#
#d={100:"poorna",200:"mathi",300:"maanav"}
#del d[100]
#print(d)
#[Link]()
#get- to get the value associated with the key
#d={100:"poorna",200:"mathi",300:"maanav"}
#print([Link](500))
#pop(),keys(),values(),len()
#d={100:"poorna",200:"mathi",300:"maanav"}
#print([Link]())
#print(d)
#d={100:"poorna",200:"mathi",300:"maanav"}
#print([Link]())
#for i in [Link]():
# print(i)
#d={100:"poorna",200:"mathi",300:"maanav"}
#print([Link]())
#for i in [Link]():
# print(i)
functions
----------
4 types of argument
positional arg
keyword arg
default arg
variable length arg
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 28 [Link] 2021
@author: Poorni
"""
#def fun_name(parameters):
# """doc string"""
#...
#...
#return value
#def manadatory,return,paramters(optional)
#functions
#----------------
#def f1():
# print("Hello")
#f1()
#print(f1())
#if we are not wirting return statement
#then default value is none
#############################
#def add(x,y):
# return x+y
#result=add(10,20)
#print("The sum is",result)
#print("The sum is",add(100,200))
###############
#Returning multiple values from a function:
#
#def sum_sub(a,b):
# sum=a+b
# sub=a-b
# return sum,sub
#x,y=sum_sub(100,50)
#print("The Sum is :",x)
#print("The Subtraction is :",y)
##############
#positional arg,keyword arg,default arg,variable length
#arg
#keyword arguments
##we can pass argument values by keyword ie parameter name
#here the order of argments is not important,but no of arg
#should match
#def wish(name,msg):
# print("Hello",name,msg)
#wish(name="Poorna",msg="Good Morning")
#wish(msg="Good Morning",name="poorna")
########
#Default Arguments
#
#def wish(name="Guest"):
# print("Hello",name,"Good Morning")
#
#wish("poorna")
#wish()
#positional arg
#def sub(a,b):
# print(a-b)
# sub(100,200)
# sub(200,100)
####################
#Variable length arguments:
#syntax------ def f1(*n):
#
#def sum(*n):
# total=0
# for n1 in n:
# total=total+n1
# print("The Sum=",total)
#sum() #zero no of arg passed
#sum(10)
#sum(10,20)
#sum(10,20,30,40)
##############3
#We can mix variable length arguments with positional arguments
#
#def f1(n1,*s):
# print(n1)
# for s1 in s:
# print(s1)
#
#f1(10)
#f1(10,20,30,40)
#f1(10,"A",30,"B")
############################
#keyword arguments
#
#def display(**kwargs):
# for k,v in [Link]():
# print(k,"=",v)
#display(n1=10,n2=20,n3=30)
#display(rno=100,name="Poorna",marks=70,subject="Java")
##########################
#Global Variables
#a=10 # global variable
#def f1():
# print(a)
#
#def f2():
# print(a)
#f1()
#f2()
###############
#Local Variables
#Local variables are available only for the function in which we declared it.i.e
from outside
#of function we cannot access.
#def f1():
# a=10
# print(a) # valid
#
#def f2():
# print(a) #invalid
#
#f1()
#f2()
####################
#global keyword
#to declare global variable inside function
#to make global variable avaialbale to the function
#so that we can perform required modification
#
#a=10
#def f1():
# global a
# a=777
# # print(a)
#def f2():
# print(a)
#f1()
#f2()
#a=10
#def f1():
#
# a=777
# print(a)
# print(globals()['a'])
#
#print(a)
#f1()
#####################
#Recursive Functions
#
#def factorial(n):
# if n==0:
# result=1
# else:
# result=n*factorial(n-1)
# return result
#print("Factorial of 4 is :",factorial(4))
#print("Factorial of 5 is :",factorial(5))
#############################
#Lamda or anonymous function//for instant use
#syntax--- lambda argument:expression, lambda function returns expression
#value and we are not required to write any return statement
#explicitily
#lambda argument_list:expression
#s=lambda n:n*n
#print("The Square of 4 is :",s(4))
#print("The Square of 5 is :",s(5))
#lambda function can be used to pass function as arg to
#another function
######################
#s=lambda a,b:a+b
#print("The Sum of 10,20 is:",s(10,20))
#print("The Sum of 100,200 is:",s(100,200))
######################
#without lamda
#def isEven(x):
# if x%2==0:
# return True
# else:
# return False
#
#l=[0,5,10,15,20,25,30]
#l1=list(filter(isEven,l))
#print(l1) #[0,10,20,30]
###########################
#with lamda
###
#l=[0,5,10,15,20,25,30]
#l1=list(filter(lambda x:x%2==0,l))
#print(l1) #[0,10,20,30]
#l2=list(filter(lambda x:x%2!=0,l))
#print(l2)#[5,15,25]
#######################
#map unction is used to generate new element with the
#required modification
#wihtout lamda
#l=[1,2,3,4,5]
#def doubleIt(x):
# return 2*x
#l1=list(map(doubleIt,l))
#print(l) #[2, 4, 6, 8, 10]
#
##with lamda
#
#l=[1,2,3,4,5]
#l1=list(map(lambda x:2*x,l))
#print(l) #[2, 4, 6, 8, 10]
File operations
----------
text file- to store character data
binary fie- audio,videos...
open the file
------
open()
f= open(filename,mode)
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 28 [Link] 2021
@author: Poorni
"""
"""r -open an existing file with read mode,file pointer is positoned at the
begining of the file
w -" " "with write mode,if file already contains data,
it will be overridden,if file not avaiable, it creates new file
a - open file with append operation,it wont override
the data
r+ read and write data to the file,no override
a+ append and read data from the file,no override
w+ to write and read the data+override existing data
x to open a file with exclusive mode for write operation
for binary file suffixed with b
rb,wb,ab,r+b,w+b,a+b,x+b
[Link]()
properties
------------
name
mode
closed-boolean value file closed or not
readable()- boolan value file is readable or not
writable()
"""
##
#f=open("[Link]",'w')
#print("File Name: ",[Link])
#print("File Mode: ",[Link])
#print("Is File Readable: ",[Link]())
#print("Is File Writable: ",[Link]())
#print("Is File Closed : ",[Link])
#[Link]()
#print("Is File Closed : ",[Link])
#Write into the file
#
#f=open("[Link]",'w')
#[Link]("welcome\n")
#[Link]("to\n")
#[Link]("Python Programming \n")
#print("Data written to the file successfully")
#[Link]()
#Read all data from file
#
#f=open("[Link]",'r')
#data=[Link]()
#print(data)
#[Link]()
"""
read()-read total data from the file
read(n)- to read 'n' characters from the file
readline()- read only one line
readlines()- to read all the lines """
#To read only first 10 characters:
#f=open("[Link]",'r')
#data=[Link](10)
#print(data)
#[Link]()
#To read data line by line:
#f=open("[Link]",'r')
#line1=[Link]()
#print(line1,end='')
#line2=[Link]()
#print(line2,end='')
#line3=[Link]()
#print(line3,end='')
#[Link]()
#To read all lines into list:
#f=open("[Link]",'r')
#lines=[Link]()
#for line in lines:
# print(line,end='')
#[Link]()
#
#f=open("[Link]","r")
#print([Link](3))
#print([Link]())
#print([Link](4))
#print("Remaining data")
#print([Link]())
#With statement
##
#with open("[Link]","w") as f:
# [Link]("Welcome\n")
# [Link]("to\n")
# [Link]("Cognizant Digital Business\n")
#print("Is File Closed: ",[Link])
""" tell- return the current position of the file pointer
"""
#Tell and seek()
#
#f=open("[Link]","r")
#print([Link]())
#print([Link](2))
#print([Link]())
#print([Link](3))
#print([Link]())
"""seek- to move cursor to specified location."""
##
#data="Welcome to Python Programming"
#f=open("[Link]","w")
#[Link](data)
#with open("[Link]","r+") as f:
# text=[Link]()
# print(text)
# print("The Current Cursor Position: ",[Link]())
# [Link](17)
# print("The Current Cursor Position: ",[Link]())
# [Link]("GEMS!!!")
# [Link](0)
# text=[Link]()
# print("Data After Modification:")
# print(text)
#File exists or not
#import os,sys
#fname=input("Enter File Name: ")
#if [Link](fname):
# print("File exists:",fname)
# f=open(fname,"r")
#else:
# print("File does not exist:",fname)
# [Link](0)
#print("The content of file is:")
#data=[Link]()
#print(data)
# no of characters present in the file
#
#import os,sys
#fname=input("Enter File Name: ")
#if [Link](fname):
# print("File exists:",fname)
# f=open(fname,"r")
#else:
# print("File does not exist:",fname)
# [Link](0)
#lcount=wcount=ccount=0
#for line in f:
# lcount=lcount+1
# ccount=ccount+len(line)
# words=[Link]()
# wcount=wcount+len(words)
#print("The number of Lines:",lcount)
#print("The number of Words:",wcount)
#print("The number of Characters:",ccount)
#wRITING DATA TO CSV
#
#import csv
#with open("[Link]","w",newline='') as f:
# w=[Link](f) # returns csv writer object
# [Link](["ENO","ENAME","ESAL","EADDR"])
# n=int(input("Enter Number of Employees:"))
# for i in range(n):
# eno=input("Enter Employee No:")
# ename=input("Enter Employee Name:")
# esal=input("Enter Employee Salary:")
# eaddr=input("Enter Employee Address:")
# [Link]([eno,ename,esal,eaddr])
#print("Total Employees data written to csv file successfully")
#Reading Data from csv file:
#import csv
#f=open("[Link]",'r')
#r=[Link](f) #returns csv reader object
#data=list(r)
##print(data)
#for line in data:
# for word in line:
# print(word,"\t",end='')
# print()
# file zip
#
#from zipfile import *
#f=ZipFile("[Link]",'w',ZIP_DEFLATED)
#[Link]("[Link]")
#[Link]("[Link]")
#[Link]()
#print("[Link] file created successfully")
#Unzipping
#
#from zipfile import *
#f=ZipFile("[Link]",'r',ZIP_STORED)
#names=[Link]()
#for name in names:
# print( "File Name: ",name)
# print("The Content of this file is:")
# f1=open(name,'r')
# print([Link]())
# print()
#import os
#cwd=[Link]()
#print(cwd)
#import os
#[Link]("subdir")
#import os
#[Link]("subdir")
-----------------------------
exception
----------------
syntax
runtime
78
...100
try- risky code
except(catch in java)//handler
without try-except
-----------
print("hello")
print(10/0)//zerodivsion error
print("statement")
o/p
---
hello
with try except
-------------
print("hello")
try:
print(10/0)//zerodivsion error
except ZeroDivisionError:
print(10/2)
print("statement")
o/p
---
hello
5
statement
try:
code
except:
handller code
finally:
cleanup code
class classname:
instance var
local var
static var
__init__//constructor
class
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 28 [Link] 2021
@author: Poorni
"""
#
#class Student:
# def__init__(self,name,age,mark):
# [Link]=name
# [Link]=age
# [Link]=mark
#
# def method(self):
# print("hello",[Link])
# print("age is",[Link])
# print("my mark is",[Link])
#
#referencevariable=clsssname()
#
#s=Student();
#[Link]();
#class Student:
#
# def __init__(self,name,rollno,marks):
# [Link]=name
# [Link]=rollno
# [Link]=marks
#
# def talk(self):
# print("Hello My Name is:",[Link])
# print("My Rollno is:",[Link])
# print("My Marks are:",[Link])
#s1=Student("Poorna",101,80)
#[Link]()