python
'''search perticlar string ki occurence ko find karta h
or findall pure occurence ko find karta h
(r)-raw string is liye lagate h ki vo character ko special treat/perform
na kare jise string h vasehi return kare'''
import re
'''group-
span-index value deta h
start-fist value dega or last value dega
maches-sef starting me search karta h
finditer-iterater object return karta h kisi bhi string ka
'''
##matched_result=re.search('sun',"the sun is up")
##
##print("Match:",matched_result.group())
##
##print("Span:",matched_result.span())
##
##print("Starting_Index:",matched_result.start())
##
##print("Ending_ ndex:",matched_result.end())
##
##string='sun is up'
##
##matched_result=re.match('sun',string)
##print(matched_result)
##aString='the dog run in a random way'
##
##'''match iterator ka name h'''
##
##match=re.finditer('ran',aString)
####print(list(match))
####print(match)
##
##for i in match:
## print(i)
#### print(("span"),i.span())
## print(("Start Index"),i.start())
## print(("End Index"),i.end())
##
'''-----------------QUANTIFIERS()'''
##text='apple pineapple'
##patten=r'a+'
##matches=re.findall(patten,text)
##print(matches)
'''quantifiers=(?)-mathes zero or one time'''
##text='color colours'
####patten=r'colou?r'
##patten=r'colou?rs'
##matches=re.findall(patten,text)
##print(matches)
'''(*)-matches zero or more time'''
##text ='apple pineapple'
####patten=r'a*'
##patten=r'p*'
##matches=re.findall(patten,text)
##print(matches)
'''({})-matches exactly n times(consecusly)'''
##text ='apple pineapple'
####patten=r'a{2,4}'
##patten=r'p{2,6}'
##matches=re.findall(patten,text)
##print(matches)
'''(IGNORECASE)-a flag that allow for case-insensitive matches'''
##pattern=r'hello'
##text='Hello there!'
##matches=re.search(pattern,text,re.IGNORECASE)
##print(matches)
##'''with compile'''
##import re
##patten=re.compile(r'hello')
##text='Hello there!'
##match=re.search(patten,text)
##print(match)
##if match:
## print("Match found!")
##else:
## print("Not found!")
##patten=re.compile(r'hello',re.IGNORECASE)
##test='Hello there!'
##match=re.search(patten,text)
##if match:
## print("Match found!")
##else:
## print("Not found!")
'''remove newlines'''
##randStr='''This is a long
## string taht goes
## on four many lines'''
####print(randStr)
##
##
##match=re.sub("\n","",randStr)
##print(match)
##phone="567-3746-3767"
##print(re.search("\d{3}-\d{4}-\d{4}",phone))
##\w meaning(a-zA-Z0-9) ye is ko sarch kar deta h--------------
##or \s space ko find karta h-------------------
##name='John Doe'
##n=re.findall("\w{4}\s\w{3}",name)
##print(n)
##x="I got 90 marks in maths"
##print(re.findall(r"\D{1,30}",x))
##
##
##print(re.findall(r"\D+","Hello 123"))
##numStr="123 1234 12345 123456 1234567 12345678 123456789"
##print(re.findall(r"\d{5,7}",numStr))
##
##print(re.findall(r"\bd{5,7}\b",numStr))
##print(re.findall(r"\b\d{5,7}\b",numStr))
##PhoneNum="0755-2345192 0755-5690432 075-5647381"
##
##print(re.findall(r"\d{4}-\d{7}",PhoneNum))
##
##
##print(re.findall(r"\d{3,4}-\d{7}",PhoneNum))
##
##print(re.findall(r"\d{4}-\d{7}",PhoneNum))
-------------------------------------------10224.py--------------------------------
##phNum="412-577-1212"
##
##if re.search("\w{3}-\w{3}-\w{4}",phNum):
## print("It is a phone Number")
##else:
## print("Invalid")
##email="""@grow_526gmail.com.com
##5563_tr.@yahoo.com
##limit.less@hotmail.com"""
##
##mail=re.findall("[\w\._%+-]{1,20}@[\w]{1,10}\.[\w]{1,10}",email)
##print(mail)
##parantheses ke under jo de diya us ko grupping khate h
##astring="Call me on 412-6457-8877"
##matches=re.findall(r"412-(.*)",astring)
##print(matches)
##astring="Call me on 412-6457-8877"
##matches=re.findall(r"412-(.*)",astring)
##print(matches)
##dstring="The most commonly occuring natural disaster is earthquake"
##matches=re.findall(r"(earth)quake",dstring)
##print(matches)
##randStr="1.Cat 2.Dog 3.Rat 4.Panther 5.Camel 6.Hen"
##regex=re.compile(r"\d\.(Dog|Panther|Cow)")
##matches=re.findall(regex,randStr)
##print(matches)
##Astring="21-05-1950 22-02-77"
##
##regex=re.compile(r"(\d{1,2})-(\d{1,2})-(\d{1,4})")
##
##matches=re.search(regex,Astring)
##print(matches)
##
##print("My D.O.B. =",matches.group())
##print("My Birth Date =",matches.group(1))
##print("My Birth Month =",matches.group(2))
##print("My Birth Year=",matches.group(3))
-----------------------------------------20924.py-----------------------------------------
'''search perticlar string ki occurence ko find karta h
or findall pure occurence ko find karta h
(r)-raw string is liye lagate h ki vo character ko special treat/perform
na kare jise string h vasehi return kare'''
import re
'''group-
span-index value deta h
start-fist value dega or last value dega
maches-sef starting me search karta h
finditer-iterater object return karta h kisi bhi string ka
'''
##matched_result=re.search('sun',"the sun is up")
##
##print("Match:",matched_result.group())
##
##print("Span:",matched_result.span())
##
##print("Starting_Index:",matched_result.start())
##
##print("Ending_ ndex:",matched_result.end())
##
##string='sun is up'
##
##matched_result=re.match('sun',string)
##print(matched_result)
##aString='the dog run in a random way'
##
##'''match iterator ka name h'''
##
##match=re.finditer('ran',aString)
####print(list(match))
####print(match)
##
##for i in match:
## print(i)
#### print(("span"),i.span())
## print(("Start Index"),i.start())
## print(("End Index"),i.end())
##
'''-----------------QUANTIFIERS()'''
##text='apple pineapple'
##patten=r'a+'
##matches=re.findall(patten,text)
##print(matches)
'''quantifiers=(?)-mathes zero or one time'''
##text='color colours'
####patten=r'colou?r'
##patten=r'colou?rs'
##matches=re.findall(patten,text)
##print(matches)
'''(*)-matches zero or more time'''
##text ='apple pineapple'
####patten=r'a*'
##patten=r'p*'
##matches=re.findall(patten,text)
##print(matches)
'''({})-matches exactly n times(consecusly)'''
##text ='apple pineapple'
####patten=r'a{2,4}'
##patten=r'p{2,6}'
##matches=re.findall(patten,text)
##print(matches)
'''(IGNORECASE)-a flag that allow for case-insensitive matches'''
##pattern=r'hello'
##text='Hello there!'
##matches=re.search(pattern,text,re.IGNORECASE)
##print(matches)
##'''with compile'''
##import re
##patten=re.compile(r'hello')
##text='Hello there!'
##match=re.search(patten,text)
##print(match)
##if match:
## print("Match found!")
##else:
## print("Not found!")
##patten=re.compile(r'hello',re.IGNORECASE)
##test='Hello there!'
##match=re.search(patten,text)
##if match:
## print("Match found!")
##else:
## print("Not found!")
'''remove newlines'''
##randStr='''This is a long
## string taht goes
## on four many lines'''
####print(randStr)
##
##
##match=re.sub("\n","",randStr)
##print(match)
##phone="567-3746-3767"
##print(re.search("\d{3}-\d{4}-\d{4}",phone))
##\w meaning(a-zA-Z0-9) ye is ko sarch kar deta h--------------
##or \s space ko find karta h-------------------
##name='John Doe'
##n=re.findall("\w{4}\s\w{3}",name)
##print(n)
##x="I got 90 marks in maths"
##print(re.findall(r"\D{1,30}",x))
##
##
##print(re.findall(r"\D+","Hello 123"))
##numStr="123 1234 12345 123456 1234567 12345678 123456789"
##print(re.findall(r"\d{5,7}",numStr))
##
##print(re.findall(r"\bd{5,7}\b",numStr))
##print(re.findall(r"\b\d{5,7}\b",numStr))
##PhoneNum="0755-2345192 0755-5690432 075-5647381"
##
##print(re.findall(r"\d{4}-\d{7}",PhoneNum))
##
##
##print(re.findall(r"\d{3,4}-\d{7}",PhoneNum))
##
##print(re.findall(r"\d{4}-\d{7}",PhoneNum))
##phNum="412-577-1212"
##
##if re.search("\w{3}-\w{3}-\w{4}",phNum):
## print("It is a phone Number")
##else:
## print("Invalid")
##email="""@grow_526gmail.com.com
##5563_tr.@yahoo.com
##limit.less@hotmail.com"""
##
##mail=re.findall("[\w\._%+-]{1,20}@[\w]{1,10}\.[\w]{1,10}",email)
##print(mail)
##parantheses ke under jo de diya us ko grupping khate h
##astring="Call me on 412-6457-8877"
##matches=re.findall(r"412-(.*)",astring)
##print(matches)
##astring="Call me on 412-6457-8877"
##matches=re.findall(r"412-(.*)",astring)
##print(matches)
##dstring="The most commonly occuring natural disaster is earthquake"
##matches=re.findall(r"(earth)quake",dstring)
##print(matches)
##randStr="1.Cat 2.Dog 3.Rat 4.Panther 5.Camel 6.Hen"
##regex=re.compile(r"\d\.(Dog|Panther|Cow)")
##matches=re.findall(regex,randStr)
##print(matches)
##Astring="21-05-1950 22-02-77"
##
##regex=re.compile(r"(\d{1,2})-(\d{1,2})-(\d{1,4})")
##
##matches=re.search(regex,Astring)
##print(matches)
##
##print("My D.O.B. =",matches.group())
##print("My Birth Date =",matches.group(1))
##print("My Birth Month =",matches.group(2))
##print("My Birth Year=",matches.group(3))
------------------------------------92324.py-----------------------------
##Define a class named Book with three attributrs:title,author,& pages
##Implement a method called discription() that return a string representation
##of the class
##class Book:
## def __init__(self,title,author,pages):
## self.title=title
## self.author=author
## self.pages=pages
## def Discription(self):
## print(f"The title of book is {self.title},and the author of book is {self.author}and it's pages{self.pages}")
##
##obj1=Book("Operating system","Galvin",1002)
##obj1.Discription()
##class Book:
## def __init__(self,title,author,pages):
## self.title=title
## self.author=author
## self.pages=pages
## def Discription(self):
## return(f"The title of book is {self.title}, and the author of book is {self.author} and it's pages{self.pages}")
##
##obj1=Book("Operating system","Galvin",1002)
##print(obj1.Discription())
#OPERATOR OVERLODING
##class X:
## def __init__(self,a,b):
## self.num1=a
## self.num2=b
## def __add__(self,other):
## print(self.num1+other.num1)
## print(self.num2+other.num2)
##obj1=X(2,3)
##obj2=X(5,5)
##obj3=obj1+obj2
##class X:
## def __init__(self,a,b):
## self.num1=a
## self.num2=b
##obj1=X(2,3)
##print(obj1.num1+obj1.num2)
##print(int.__add__(2,3))
#
##class X:
## def __init__(self,a,b):
## self.num1=a
## self.num2=b
## def __add__(self,other):
## print(self.num1+other.num2)
## print(self.num1+other.num2)
##
##obj1=X(2,2)
##obj2=X(5,6)
##obj3=obj1+obj2
##class X:
## def __init__(self,name,age,place):
## self.name=name
## self.age=age
## self.place=place
## def __add__(self,other):
## print(self.nume+other.nume)
## print(self.age+other.age)
## print(self.place+other.place)
##
##o1=X("Sam",25,"japan")
##o2=X("pam",29,"germany")
##o3=o1+o2
#METHOD OVERLODING
##class X:
## def add(self,a,b):
## return a+b
## def add(self,a,b,c=0):
## return a+b+c
##obj=X()
##print(obj.add(2,4))
#METHOD OVERLODING
##class X:
## def add(self,*args):
## n=0
## for i in args:
## n+=i
## return n
##obj=X()
##print(obj.add(2,4,5,6,7))
#FACTORIAL
##class X:
## def mult(self,*args):
## n=1
## for i in args:
## n*=i
## return n
##obj=X()
##print(obj.mult(1*2*3*4*5))
##class Father:
## def Eat(self):
## print("DalRooti")
## def Work(self):
## print("Drive")
##class Son(Father):
## pass
##obj=Son()
##obj.Eat()
##obj.Work()
##METHOD OVERRIDING
##overwrite kar raha h same name ke method ko
##class Father:
## def Eat(self):
## print("DalRooti")
## def Work(self):
## print("Drive")
##class Son(Father):
## def Eat(self):
## print("Eat junk food")
##obj=Son()
##obj.Eat()
##obj.Work()
##Super method
##class Father:
## def Eat(self):
## print("DalRooti")
#### super().Eat()
## def Work(self):
## print("Drive")
##class Son(Father):
## def Eat(self):
## super().Eat()
## print("Eat junk food")
#### super().Eat()
##obj=Son()
##obj.Eat()
##obj.Work()
##class Father:
#### def __init__(self,name,house):
#### self.name=name
#### self.house=house
#### def Desc(self):
#### print(f"The name is {self.name} and it's house is {self.house}")
## def Eat(self):
## print("DalRooti")
## def Work(self):
## print("Drive")
##class Son(Father):
## def Eat(self):
## print("Eat junk food")
## p
##obj=Son()
##obj.Eat()
##obj.Work()
##class Father:
## def __init__(self,name,house):
## self.name=name
## self.house=house
##class Son(Father):
## pass
##objDad=Father("hary","1 house")
##print(objDad.name)
##obj=Son("jerry","WhiteHouse")
##print(obj.name)
##class Parent:
## def display(self):
## print("Hello !")
## def display(self,astring):
## print("Hi!!",astring)
##class Child(Parent):
## def display(self):
## print("Hello !!")
##p=Parent()
##p.display("hi")
####p.display("There")
##c=Child()
##c.display()
##
##class Parent:
## def display(self):
## print("Hello !")
## def display(self,astring):
## print("Hi!!",astring)
##class Child(Parent):
## def display(self):
## print("Hello !!")
##p=Parent()
##p.display("hi")
##c=Child()
##c.display()
##
##class Parent:
## def display(self):
## print("Hello !")
## def display(self,astring):
## print("Hi!!",astring)
##class Child(Parent):
## def display(self):
## print("Hello !!")
##c=Child()
##c.display()
##class Father :
## def eat(self):
## print("i eat healthy food")
## def work(self):
## print("i go to office work")
##class Son(Father):
## def eat(self):
## print("i eat junk food")
## super().eat()
##obj=Son()
##obj.eat()
#9/24/2024
##class Parent:
## def display(self):
## print("hello 1")
## def display(self,a):
## print("hi !",a)
##
##class Child(Parent):
## def display(self,a=None):
## print("hello 2")
## super().display(a)
####obj1=Parent()
##obj=Child()
##obj.display()
##obj.display("There")
#ATTRUBUTE OVERRIDING
##class Student:
## def __init__(self,name,student_id,grade):
## self.name=name
## self.student_id=student_id
## self.grade=grade
##
## def get_info(self):
## pass
#### (f"The name is {self.name} and student_id {self.student_id} and it's grade is{self.grade}")
##
##class Undergraduate(Student):
## def __init__(self,name,student_id,grade,major,year):
## super().__init__(name,student_id,grade)
## self.major=major
## self.year=year
##
## def get_detail(self):
##
## return(f"The name is {self.name} and student_id {self.student_id} and it's grade is{self.grade},The major subject is {self.major} year is {self.year}")
##
####obj=Student("Ashu",102,"B")
####print(obj.get_info())
##obj1=Undergraduate("Ibu",103,"A","Python",2023)
##print(obj1.get_detail())
#POLYMOR
#DUCK TYPING
##class Bird:
## def fly(self):
## return"A bird flies in the sky"
##class Airplane:
## def fly(self):
## return"Airplane flies in the sky"
##class Glass:
## def useful_vessel(self):
## return"Glass contain water"
##
##def Make_it_fly(obj):
## return obj.fly()
##
##sparrow=Bird()
##jet=Airplane()
##objGlass=Glass()
##print(Make_it_fly(sparrow))
##print(Make_it_fly(jet))
##print(Make_it_fly(Glass))
##class Duck:
## def sound(self):
## return"Quick!"
##class Dog:
## def sound(self):
## return"Woof!"
##class Cat:
## def sound(self):
## return"Meow!"
##
##def Make_it_sound(obj):
## return obj.sound()
##
##Quick=Duck()
##Woof=Dog()
##Meow=Cat()
##print(Make_it_sound(Quick))
##print(Make_it_sound(Woof))
##print(Make_it_sound(Meow))
##ABSTRACT CLASS
#object does not return
##from abc import ABC, abstractmethod
##
##class Vehical(ABC):
## @abstractmethod
## def drive (self):
## pass
##obj=Vehical()
##print(obj)
##from abc import ABC, abstractmethod
##class Vehical(ABC):
## @abstractmethod
## def drive (self):
## pass
##class Car(Vehical):
## def drive (self):
## print("Cars are begin drive on road")
##class Truck(Car):
## def drive(self):
## print("Truck are begin drive on road")
##C=Truck()
##C.drive()
##D=Car()
##D.drive()
##9/26/24
##class Duck:
## def __init__(self,wings,weight):
## self.wings=wings
## self.weight=weight
## def fly(self):
## pass
## def quick(self):
## pass
##class Rubber_Duck(Duck):
## def detail(self):
## print("Wings {self.seight} ,Weight{self.weight}")
##
## def fly(self):
## return("I dont fly")
## def quick(self):
## return("I don't quick")
##
##obj1
##Recursion
#It's infinite but 1010 more time value return useing recurtion method
##def Greeting():
## print("Hello World!")
##
## Greeting()
##Greeting()
#Find factorial use Recursion Method
##def Factorial(n):
## if n==0 or n==1:
## return 1
##
## return n*Factorial(n-1)
##result=Factorial(5)
##print(result)
##class Animal:
## def __init__(self,name):
## self._name=name
##class Cat(Animal):
## def meow(self):
## return f"{self.name} says Meow!"
##
##my_cat=Cat("Kitty")
##
##my_cat.name="Snowie"
##print(my_cat.meow())
##class BankAccount:
## def __init__(self,balance):
## self.__balance=balance
##
##account=BankAccount(1000)
##account.__balance=3000
###
##
##class BankAccount:
## def __init__(self,balance):
## self.__balance=balance
##def get_balance(self):
## return self.__balance
##
##print(account.get_balance())
##class BankAccount:
## def __init__(self,balance):
## self.__balance=balance
##def get_balance(self):
## return self.__balance
##account=BankAccount(1000)
## #name managing
##print(account.__BankAcount__balance)
##account.__BankAcount__balance=9000
##print(account.get_balance())
##class BankAccount:
## def __init__(self,balance):
## self.__balance=balance
##
## @property#getter method
## def balance(self):
## return self.__balance
##
##account=BankAccount("200")
##print(account.balance)
####account.balance=300
#Encapsulation
##class BankAccount:
## def __init__(self,balance):
## self.__balance=balance
##
## @property#getter method
## def balance(self):
## return self.__balance
##
## @balance.setter#setter method
## def change_balance(self,value):
## self.__balance=value
##
##account=BankAccount("200")
##print(account.balance)
##account.change_balance=("300")
##class Employee:
## def __init__(self,name='abc',age='50',salary='500'):
## self.name=name
## self.__age=age
## self.__salary=salary
####
## @property
## def detail(self):
## return self.__age
##
## @detail.setter
## def change(self,value):
##
## self.__age=value
## @property
## def detail(self):
## return self.__salary
##
## @detail.setter
## def change(self,val):
## self.__salary=val
##
##obj=Employee()
##print(obj.detail)
##obj.change=18
##print(obj.detail)
##class Book:
## def __init__(self,title='Operating System'):
## self.__title=title
##
## @property
## def Change(self):
## return self.__title
## @Change.setter
## def detail(self,val):
## self.__title=val
##
##obj=Book()
##print(obj.Change)
##obj.Change="Network"
##print(obj.Change)
#REGULAR EXPRESTION
##import re
##animalstr='cat rat mat bat cat sat Mat Cat pat hat fat'
####print(re.search('cat',animalstr))
##
####print(re.findall('cat',animalstr))
##
####print(re.findall('[cC]at',animalstr))
##
####print(re.findall('[^bsmM]at',animalstr))
##
## string=re.findall('[c-m]at',animalstr)
##print(string)
##import re
##string1='earth revolves round the sun'
##n=re.compile('earth')
##finalre=re.sub(n,'moon',string1)
##print(finalre)
##string1='earth revolves round the sun'
##finalre=re.sub('earth','moon',string1)
##print(finalre)
##import re
##string="here is \\stuff"
##search=re.search(r"\\stuff",string)
##print(search)
##string="here is \\stuff"
##search=re.search("\\\stuff",string)
##print(search)
##import re
####
######randStr="F.B.I I.R.S CIA Dr. Mr."
######search=re.search(".",randStr)
######print(search)
####
####
##Str="F.B.I. I.R.S. CIA Dr. Mr."
##print("Matches:",re.findall("\..\..\.",Str))
##import re
##Str="F.B.I. I.R.S. CIA Dr. Mr."
##print("Matches:",re.findall("\..\..\..\...\",Str))
##class Animal:
## def __init__(self,name):
## self._name=name
##
##class Cat(Animal):
## def Meaw(self):
## return f"{self._name} says meaw"
##
##obj=Cat("Kitty")
##print(obj.Meaw())
##print(obj._name)#possible but not recommendat
##obj2=Animal("xyz")
##print(obj2._name)
##9/27/24
#STATIC METHOD
##class X:
## def add(x,y):#without decorator
## return x+y
##print(X.add(2,5))
##
##class Y:
## @staticmethod
## def mult(x,z):#using decorator staticmethod
## return x*z
##print(Y.mult(2,3))
##class Laptop:
## def code(self):
## return "Typing code..."
##class Smartphone:
## def code(self):
## return "Swipping on screen..."
##def Start_coding(obj):
## return obj.code()
##
##typing=Laptop()
##print(Start_coding(typing))
##
##Swipping=Smartphone()
##print(Start_coding(Swipping))
##from abc import ABC, abstractmethod
##
##class Person(ABC):
## @abstractmethod
## def Introduce(self):
## pass
## @abstractmethod
## def Role(self):
## pass
##
##class Student(Person):
## def __init__(self,name,grade):
## self.name=name
## self.grade=grade
## def Role():
## return "I am a Student"
## def Introduce(self):
## return f"The name of student is {self.name} and it's grade is {self.grade}"
##class Teacher(Person):
## def __init__(self,name,subject):
## self.tname=name
## self.subject=subject
## def Introduce(self):
## return f"The tacher name is {self.tname} and subject is {self.subject}"
## def Role(self):
## return "I am a teacher"
##obj=Teacher("ana","english")
##print(obj.Introduce())
##obj=Student("Anju","A")
##print(obj.Introduce())
##print(obj.Role())
import re
##animalstr="cat rat mat bat sat Mat Cat pat hat fat"
##
##print(re.search("cat",animalstr))
##print(re.findall("cat",animalstr))
##print(re.findall("[cC]at",animalstr))
##print(re.findall("[^bsmM]at",animalstr))
##print(re.findall("[c-m]at",animalstr))
##str1="earth revolve around the sun"
##n=re.compile("erth")
####print(re.sub(n,"moon",str1))
##f=n.sub(n,"moon",str1)
##print(f)
##randStr="F.B.I. I.R.S CIA Dr. Mr."
##print(re.search(".",randStr))
##print("Matches:",re.findall("[D,M]r.",randStr))
##print("Matches:",re.findall("\...\..\...\..\ ",randStr))
import re
animal='dog frog cat dog rat cat'
print(re.search("frog",animal))
print(re.findall("[^d]og",animal))
print(re.findall("[a-f]at",animal))
n=re.compile("cat")
print(re.sub(n,"lion",animal))
##print(re.findall("",animal))
----------------------------------1609024.py---------------------------------------------------------
#Exception-normal(all error uses)
'''num1=int(input('enter the number:'))
num2=int(input('enter the number:'))
try:
print(num1/num2)
except Exception as e:
print('incorrect program',e)
print('hello world')
#Exception-Specific Error
num1=int(input('enter the number:'))
num2=int(input('enter the number:'))
try:
print(num1/num2)
except ZeroDivisionError as e:
print('incorrect program',e)
print('hello world')
#
num1=int(input('enter the number:'))
num2=int(input('enter the number:'))
try:
print(num1/num2)
except ZeroDivisionError as e:
print('incorrect program',e)
finally:
print('end of program')
print('hello world') '''
##def weight(n):
## try:
## return int(n)
## except ValueError as ex:
## print(ex)
##w=weight('ten pound')
##print(w)
##print("program terminated")
##def weight(n):
## try:
## return int(n)
## except ValueError as ex:
## print(ex)
##w=weight('10')
##print(w)
##print("program terminated")
##
##def weight(n):
## try:
## return int(n)
## except Exception as ex:
## print(ex)
##w=weight('ten pound')
##print(w)
##print("program terminated")
##def devide(num1/num2):
## try:
## result=num1/num2
## except ZeroDivisionError:
## return("error:divison by zero is not allowed.")
## except Exception as e:
## return f"an unexcepted error{e}"
## else :
## return result()
##print(func(10,2))
##print(func(10,a))
##def func1():
## try:
## d=open('16925','r')
## print(read(),d)
## except FileNotFoundError:
## return ('error',r)
## except Exception as e:
## return ('Unexcepted error{e}')
## else:
## return lines
##result=func1('16925')
## print(result)
##def func1(n):
## try:
## with open(n,'r') as var:
## lines=var.read()
## except FileNotFoundError as e:
## return'not found'
## except Exception as ex:
## return 'incorrect'
## else:
## return lines
##result=func1("16925.py")
##print(result)
##list1=[2,3,4,5]
##def func(alist,index):
## try:
## return alist[index]
## except IndexError as error:
## return (f'index out of range {error}')
## except Exception as e:
#### return (f'an error occured {error}')
##result=func(list1,30)
##print(result)
##
####def list1(a,b):
#### try:
#### return list1[index]
#### except IndexError as e:
#### return "value does not exist"
#### except Exception as e:
## return
####li=[2,3,4,5,6]
####print(li)
####print("program terminated")
##def func1((num1/num2),(file(n)),(String(m))):
## try:
## result=num1/num2
## with open(n,'r') as var:
## lines=var.read()
## except ZeroDevisionError as e:
## return(f"zero division not except{error}")
## except FileNotFoundError as e:
## return(f'not found{error}')
## except ValueError as m:
## return int(n)
## print(m)
## except Exception as e:
## return
##func1=dict[]
'''
def myfun(n1,n2,filename,st):
try:
division-result=n1/n2:
with open(filename,'r')as file:
content=file.read()
variable=int(st)
except ZeroDivisionError:
return"can't divide by 0"
except FileNotFoundError:
return'file not found'
except ValueError:
return "can't convert letter into integer"
except Exception:
return "an unexcepter error"
else:
return {"division-result":devision-result,
"file-content":content,
"string-converted":variable}
myfun(8,2,"text",'3')
print(myfun)'''
##import math
####print(dir(math))
##print(math.factorial(5))
##
##print(math.sqrt(16))
##
##print(math.pi)
##a,b=60,48
##result=math.gcd(a,b)
##print(f"GCD of {a} and {b} is {result}")
##li=[2,3,4,5,6]
##it=iter(li)
##print(it.__next__())
##print(next(it))
##
##for i in it:
## print(i)
##
##print(next(it
##
li="hello"
for i in :
(len(str[0:6])
print(li)
Comments
Post a Comment