Page 105 - Code Craft Computer-7
P. 105
Conditional
10 Statements
in Python
Core Concepts
On completion of this chapter you will be able to know:
¨ Decision Making Statements
Warm Up #Problem Solving
There are certain rules in Python that have to be followed to form valid variable names. Write
them in the space given below.
1. __________________________________________________________________________
2. __________________________________________________________________________
3. __________________________________________________________________________
4. __________________________________________________________________________
There are situations in life when we need to decide based on a situation. For example, if it rains, I
will stay at home or else I shall 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.
We need to determine which action is to be taken and which statement is to be executed, if the
outcome is true or false.
DECISION MAKING STATEMENTS
Decision making in Python is done by using conditional statements which decide the flow of
program execution. The following conditional statements are available in Python:
• if statement
• if...else statement
• Nested if statement
• if...elif...else ladder
The if Statement
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.
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:
105

