Wednesday, September 14, 2011

Boolean Operators

After dealing with String and Arithematic operators ,its time to cover some very important operators , Boolean Operators

Boolean values are sometimes known as "truth values" because they are used to test whether something is true or not. example we are having two Strings we want to know weather the String values provided are equal or not, if they are equal we transfer pur control from one location to another.

so like in all other programming languages, in Python also we are having all basic Boolean operators::

[A and B] ----> AND ---> True if A,B are both True, False otherwise.

[A or B] ----> OR ---> True if either or both of A,B are true. False if both A and B are false

[A == B] ----> Equality ---> True if A is equal to B

[A != B
A <> B] ----> Inequality --->True if A is NOT equal to B.

[not B] ----> Negation ---> True if B is not True


Note: the last one operates on a single value, the others all compare two values.

No comments:

Post a Comment