The following table lists the logical operators supported by all Python languages. Assuming that variable a holds 10 and variable B holds 20, then:
Example:
Try the following example to understand that all Python programming languages provide logical operators:
#!/usr/bin/pythona = 10b = 20c = 0if (A and B): print "line 1-a and B is true" else: print "line 1-either a Is isn't true or B is not true "if (A or B): print" line 2-either A was true or B is true or both is true "else: P Rint "Line 2-neither A is true nor B was true" a = 0if (A and B): print "line 3-a and B is true" else: print " Line 3-either A isn't true or B is not true "if (A or B): print" line 4-either A was true or B is true or both AR E true "else: print" line 4-neither A are true nor B is true "if not (A and B): print" line 5-either A is not tr UE or B is not true "else: print" line 5-a and B is true "
When executing the above program it produces the following result:
Line 1-a and B being Trueline 2-either A is true or B is true or both be Trueline 3-either A is isn't true or B is not Trueline 4-either A is true or "B is true" or both is Trueline 5-either "is" not true or "B is" not true