-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram33.py
More file actions
79 lines (68 loc) · 1.7 KB
/
program33.py
File metadata and controls
79 lines (68 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#Exception Handling (part-1)-----------
num2 = int(input("Enter any number : "))
result = 20/ num2
print(result)
print("Done")
#Exception Handling (part-1)-----------
tex= "Aiful"
print(tex[3])
print("Done")
#Exception Handling (part-1)-----------
list = [20,0,10]
result = list[2] / list[0]
print(result)
print("Done")
#Exception Handling (part-1)-----------
try:
list = [20,0,10]
result = list[0] / list[3]
print(result)
print("Done")
except ZeroDivisionError:
print("It is not possible to print")
except IndexError:
print("Index Error")
print("Successful")
finally:
print("Successful")
#Exception Handling (part-1)-----------
try:
list = [20,0,10]
result = list[0] / list[5]
print(result)
print("Done")
except ZeroDivisionError:
print("zero division error")
finally:
print("Succesfuly")
#Exception Handling (part-2)--------
try:
num1 = int(input("Enter first number : "))
num2 = int(input("Enter second number : "))
result = num1 / num2
print(result)
print("Done")
except (ValueError,ZeroDivisionError) :
print("You have entered incorrect input")
finally:
print("Thank!!!")
#Exception Handling (part-2)--------
def vote(age):
if age < 18:
raise ValueError("Invalid Error")
return 'You are allowed to vote'
try:
print('Arif',vote(19))
print('Tamim',vote(17))
except ValueError as e:
print(e)
#Exception Handling (part-2)--------
def vote(age):
if age < 18:
raise ValueError("Invalid Error")
return "You are allowed to vote"
try:
print('Arif',vote(19))
print('Tamim',vote(17))
except ValueError as v:
print(v)