Page 112 - Touchpad_Plus_V3.2_Class 7
P. 112
10 Conditional Statements in
Python
Your Aim
to learn about:
Decision Making Statements The if Statement
The if...else Statement Nested if Statement
The if...elif...else Ladder
There are situations in life where we must make decisions based on the circumstances. For
example, if it rains, we will stay at home, or else we will visit the market. Similar situations arise in
programming as well, where we need to make some decisions and, based on these decisions,
execute a set of commands. Whether the outcome is true or false, we must decide which action
to take and which statement to execute. In this chapter, we will learn about conditional statements
in Python.
DECISION MAKING STATEMENTS Start
Conditional statements, also known as decision-making or
control flow statements, are used in programming to execute
False
different blocks of code based on certain conditions. The if condition
following Decision Making Statements are available in Python:
True
if statement if...else statement
Statements in if block
Nested if statement if…elif…else ladder
execute
THE IF STATEMENT
The if statement is the simplest conditional statement. In case Stop
of the if statement, a statement or a collection of statements
within the if block is executed only if a certain condition or expression evaluates to True. If the
condition evaluates to False, then the control of execution is passed to the next statement after
the if block. The syntax of the if statement is given below:
Clickipedia
Syntax:
if (Test Expression):
In Python, the non-zero value is interpreted as
Indented statement block
True. None and 0 are interpreted as False.
# if block ends here
110 Plus (Ver. 3.2)-VII 110

