7.5. Omitting the else Clause: Unary Selection¶
Another form of the
if statement is one in which the
else clause is omitted entirely.
This creates what is sometimes called unary selection.
In this case, when the condition evaluates to
True, the statements are
executed. Otherwise the flow of execution continues to the statement after the body of the
What would be printed if the value of
x is negative? Try it.
Check your understanding