Python Exception Handling Practical Notes
Python Exception Handling Practical Notes
# a=10
# b=20
# print(s)
# print(a+b)
# amount = 10000
#
# # check that You are eligible to
# # purchase Dsa Self Paced or not
# if(amount > 2999)
# print("You are eligible to purchase Camera")
# def Arith(a,b):
# print(a+b)
# print(a-b)
# print(a/b)
# print(a*b)
# print("All Done")
#
# Arith(40,0)
# try:
# a=5
# b=0
# print(a/b)
# except:
# print("Kuch to exception error hoga")
# print("bahar ka print statemnt")
# try:
# a=15
# b=5
# print(a/b)
# except:
# print("Kuch to exception error hoga")
# print("bahar ka print statemnt")
# try:
# def Arith(a,b):
# print(a+b)
# print(a-b)
# print(a/b)
# print(a*b)
# print("All Done")
# Arith(50,0)
# except:
# print("Excection found")
# x = int(input())
# y = int(input())
# a= int(input())
# b= int(input())
# try:
# z = x + y
# print(z)
# c = a / b
# print(c)
#
# except TypeError:
# print("Error: cannot add an int and a str")
#
#
# except ZeroDivisionError:
# print("Error: cannot divide any value by 0")
# even_numbers = [2, 4, 6, 8]
# print(even_numbers[5])
try:
even_numbers = [2, 4, 6, 8]
print(even_numbers[5])
except ZeroDivisionError:
print("Denominator cannot be 0.")
except IndexError:
print("Index Out of Bound.")
#
# # Output: Index Out of Bound
# try:
# print('try block')
# x=int(input('Enter a number: '))
# y=int(input('Enter another number: '))
# z=x/y
# except ZeroDivisionError:
# print("except ZeroDivisionError block")
# print("Division by 0 not accepted")
# except ValueError:
# print("except ValueError block")
# print("y cant be string")
#
# else:
# print("else block")
# print("Division = ", z)
# finally:
# print("finally block")
# x=0
# y=0
# print ("Out of try, except, else and finally blocks." )
#
#