Control Flow: The if
, elif
, else
Statements
Boolean Logic
Conditional statements can be formed in a compound structure by joining multiple statements using or
and and
keywords. The statements may use different variables.
The result of a conditional statement can be negated by using the not
keyword
The precedence order of these three operators are as follows: not
> and
> or
, so that in a compound conditional statement the not
operators are evaluated first, followed by the and
operators, and finally the or
operators are evaluated. However, contents of a pair of parentheses are always evaluated starting from the innermost pair of parentheses, followed by the conditional operators if any, and other parentheses.
Note: Python uses operators &
and |
for bitwise operations and they can NOT be used instead of and
and or
keywords for logical expressions.