The following table lists the comparison operators supported by all Python languages. Assuming that variable a holds 10 and variable B holds 20, then:
For example:
Try the following example to understand the comparison operators available in all Python programming languages:
#!/usr/bin/pythona = 21b = 10c = 0if (A = = B): print "line 1-a are equal to B" else: print "line 1-a are not EQ UAL to B "if (A! = b): print" line 2-a are not equal to B "else: print" line 2-a are equal to B "if (a <> b): print "line 3-a are not equal to B" else: print "line 3-a are equal to B" if (A < b): print "line 4 -A is less than B "else: print" line 4-a are not less than than B "if (A > B): print" line 5-a is greater than B "Else: print" line 5-a isn't greater than B "a = 5;b = 20;if (a <= b): print" line 6-a are either less t Han or equal to B ' else: print ' line 6-a was neither less than nor equal to B ' if (b >= a): print "Line 7- b is either greater than or equal to B "else: print" line 7-b are neither greater than nor equal to B "
When executing the above program it produces the following result:
Line 1-a isn't equal to BLine 2-a are not equal to bLine 3-a are not equal to BLine 4-a are not less than BLine 5- A is greater than bLine 6-a are either less than or equal to BLine 7-b are either greater than or equal to B