Page 38 - Modular v1.1 Pyhton
P. 38
Recap
The if statement is the simplest conditional statement.
In the if…else statement, if the condition evaluates to True, the indented block following the if
statement is executed, otherwise the indented block after the else statement is executed.
Python allows the nested if statement.
The if…elif…else ladder helps us to test multiple conditions and follows a top-down approach.
Exercise
A. Tick ( ) the correct option.
1. Which of the following conditional statements is used to test multiple conditions?
a. if b. if…else
c. if…elif…else d. All of the above
2. What will be the output of the following code?
if(True):
print("Hello")
else:
print("Hi")
a. Hello b. Hi
c. Hello Hi d. Nothing will print
3. Which of the following is not the conditional statement in Python?
a. if Statement b. if…else Statement
c. if...elif...else Statement d. None of the above
4. What is the answer of the expression, 2**2**2?
a. 2 b. 16
c. 4 d. 8
5. If a = 20 and b = 10, then what will be the output of the following code:
if (false):
print(a + b)
else:
print(a – b)
a. 30 b. 20
c. 10 d. Nothing will print
36 Touchpad MODULAR (Version 1.0)

