Page 93 - ThinkGPT_V2.1_C7_Flipbook
P. 93
if Statement Start
The if statement is the simplest conditional statement. Here,
a statement or a collection of statements within the if block is False
if condition
executed only if a certain condition or expression evaluates to
True. Otherwise, the control of execution is passed to the next
True
statement after the if block.
Statements in if
Syntax: block execute
if (condition):
Indented statement block Stop
# 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

