Page 125 - Trackpad_V4.0_c7_Flpbook
P. 125
I too want to become a programmer
like my sister. I will make a robot that
can fly and do all my work instantly.
Test Your Knowledge 21 st Century Critical Thinking
Skills
Productivity & Accountability
If a = 8, b = 2 and c = 20, then what will be the output of the following statements?
1. print(a > b and b < c) =
2. print(a ** b + c) =
3. print(a, b, c) =
4. print(a > b or b > c) =
5. print(a // b – 2 + c) =
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.
CONDITIONAL STATEMENTS
Conditional statements, also known as decision-making or control flow statements, are used in
programming to execute different blocks of code based on certain conditions. The following conditional
statements are available in Python:
if statement
if...else statement
Nested if statement
if…elif…else ladder
Conditional Statements in Python 123

