3 > 4 # OK
'3' > 4 # TypeError
2.0 >= 1 # OK
==
to compare floats. Floating point arithmetic is not exact, so the results can be confusing.
'A' and 'B'
is valid syntax, but don’t do it in this class.)and
True if and only if both operands are Trueor
True if either or both operands are Truenot
(unary operator) changes True to False and vice-versa.if
StatementsWhere EXPRESSION
can be anything that evaluates to a Boolean. For example:
if/else
StatementsExample:
Exactly one branch will be executed.
if
/elif
statementsExample
At most one branch will be executed.
if
/elif
/else
StatementsExample:
Exactly one branch will be executed.
if
StatementsExample:
No connection between the branches. Some, all, or none may occur depending on the conditions.
What will be printed?
Bad style:
Instead: