-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path07_Assertions.py
More file actions
93 lines (72 loc) · 1.56 KB
/
07_Assertions.py
File metadata and controls
93 lines (72 loc) · 1.56 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Assertions in Exception Handling :
# Example - 1 :
a=100
print(1)
print(2)
print(3)
print(4)
print(5)
print(6)
assert a==100 # is this cond true then execute next code,
# if it is false raise exception and stop the flow of execution
print(7)
print(8)
print(9)
print(10)
# Example - 2 :
a=100
print(1)
print(2)
print(3)
a=23
print(4)
print(5)
print(6)
assert a==100
print(7)
print(8)
print(9)
print(10)
# Example - 3 :
a=100
print(1)
print(2)
print(3)
a=23
print(4)
print(5)
print(6)
assert a==100,'a is not 100 it modified'
print(7)
print(8)
print(9)
print(10)
# Example - 4 :
l=['surendra','priyanka','rahul','zini','jack','scoot']
assert input('enter your name') in l
print('remaining code')
# Example - 5 :
l=['surendra','priyanka','rahul','zini','jack','scoot']
assert input('enter your name') in l,'this name is not present'
print('remaining code')
# Example - 6 :
l=['surendra','priyanka','rahul','zini','jack','scoot']
try:
assert input('enter your name') in l,'this name is not present'
except AssertionError as e:
print(e)
print('remaining code')
# Example - 7 :
l=['surendra','priyanka','rahul','zini','jack','scoot']
try:
assert input('enter your name') in l,'this name is not present'
except AssertionError as e:
print(e)
print('remaining code')
# Example - 8 :
l=['surendra','priyanka','rahul','zini','jack','scoot']
try:
assert input('enter your name') in l
except AssertionError as e:
print(e)
print('remaining code')