1#!/usr/bin/python3
2
3a = 21
4b = 10
5
6if ( a == b ):
7 print ("Line 1 - a is equal to b")
8else:
9 print ("Line 1 - a is not equal to b")
10
11if ( a != b ):
12 print ("Line 2 - a is not equal to b")
13else:
14 print ("Line 2 - a is equal to b")
15
16if ( a < b ):
17 print ("Line 3 - a is less than b" )
18else:
19 print ("Line 3 - a is not less than b")
20
21if ( a > b ):
22 print ("Line 4 - a is greater than b")
23else:
24 print ("Line 4 - a is not greater than b")
25
26a,b = b,a #values of a and b swapped. a becomes 10, b becomes 21
27
28if ( a <= b ):
29 print ("Line 5 - a is either less than or equal to b")
30else:
31 print ("Line 5 - a is neither less than nor equal to b")
32
33if ( b >= a ):
34 print ("Line 6 - b is either greater than or equal to b")
35else:
36 print ("Line 6 - b is neither greater than nor equal to b")
1# Python code to illustrate
2# chaining comparison operators
3x = 5
4print(1 < x < 10)
5print(10 < x < 20 )
6print(x < 10 < x*10 < 100)
7print(10 > x <= 9)
8print(5 == x > 4)
9