0% found this document useful (0 votes)
6 views1 page

Exception Handling Program

Exception of chemistry

Uploaded by

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

Exception Handling Program

Exception of chemistry

Uploaded by

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

Program1

#error a is not defined Program 8


print(a) Q. Program to show use of multiple except block with
else block
try:
program 2 a=int(input("Enter First Number:"))
#TYPE ERROR b=int(input("Enter Second Number:"))
c=a/b
a='ram' print("division= ",c)
b='shyam' except ZeroDivisionError:
print(a*b) print("Divide by Zero Error...")
except IndexError:
Program3 print("invalid indexing...")
#zero division error except:
a=10 print("Some thing is worng")
b=0 else:
print(a/b) print("No Errors in Try Block...")

Program 9
Program4 Program to show use of finally block with multiple
#IndexError except block
a=[5,10,15,20,25] try:
print(a[6]) a=int(input("Enter First Number:"))
b=int(input("Enter Second Number:"))
Program 5 c=a/b
try: print("division= ",c)
a=int(input("Enter First Number:")) except ZeroDivisionError:
b=int(input("Enter Second Number:")) print("Divide by Zero Error...")
c=a/b except IndexError:
print("division= ",c) print("invalid indexing...")
except: except:
print("Divide by Zero error") print("Some thing is worng")
else:
print("No Errors in Try Block...")
Program 6 finally:
try: print("Program execution Completed..")
a=[5,10,15,20,25]
print(a[5])
except ZeroDivisionError:
print("Divide by Zero Error...") Program 10
except IndexError: Q.Program to show use of raise statment
print("invalid indexing...") try:
age=int(input("Enter age:"))
if age<0:
Program 7 raise Exception
Q. Program to show use of multiple except block with print("Your Age is", age)
default except block except Exception:
try: print("age cant be negative...")
a=[5,10,15,20,25]
print(a[5]) Note:- all the studetns note down program 7 to 10 in
except: practical file with proper input and output
print("some error occourd..")
except ZeroDivisionError: Home work:- write a python program in your note
print("Divide by Zero Error...") book to show the use of assert statement
except IndexError:
print("invalid indexing...")

You might also like