Skip to content

Commit 37dd0b0

Browse files
committed
Assertions in Python
Assertions in Python
1 parent 499ddcf commit 37dd0b0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Assertions/AssertionDemo.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#Assertions are used for debbuging purpose
2+
#By default, assertions are enabled in python
3+
#To run py file by disabling assertions on client machine,run using py -O file_name.py
4+
5+
def square_it(x):
6+
return x*x
7+
8+
9+
assert square_it(2)==4,"The Square of 2 is 4"
10+
assert square_it(3)==9,"The Square of 3 is 9"
11+
assert square_it(5)==25,"The Square of 5 is 25"
12+
13+
print(square_it(2))
14+
print(square_it(4))
15+
print(square_it(5))

0 commit comments

Comments
 (0)