Page 93 - Digicode_AI_class_7
P. 93
if Statement
Test Expression False
The if statement is the simplest conditional statement. Here,
a statement or a collection of statements within the if block is
executed only if a certain condition or expression evaluates to True
True. If the condition evaluates to False, then the control of
Body of if
execution is passed to the next statement after the if block.
Syntax:
if (Test Expression):
Statement just
Indented statement block
below if
# if block ends here
In Python, the non-zero value is interpreted as true. None and 0 are interpreted
as false.
Program: To check whether a given number is positive.
On running the above program, you will get the following output:
More on Python 91

