(Fill in the blanks)
(a) A loop that repeats a specific number of times is a ______ loop.
for
(b) The ______ keyword is used to define a condition that is checked before each
iteration of a while loop.
while
(c) A ______ is an expression that evaluates to either True or False.
condition or boolean expression
(Tick the correct option)
(a) Decisions are made ______.
(iv) All of these
(b) In the if statement, if the expression is ______, the statements within if block are
executed.
(ii) True
(c) In the following code, what is the output?
Code:
a = 33
b = 34
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
(ii) b is greater than a (Since 34 > 33 is True)
(d) In the following code, what is an error?
Code:
a = 33
b = 200
if b > a:
print("b is greater than a")
(i) Expected an indented block (The print statement must be indented under the `if`
condition)
(e) The output for the following code is:
a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
(i) a and b are equal (Since 33 == 33 is True, the `elif` block executes)
(f) `print("A") if a > b else print("B")` is an example of
(i) shorthand if else statement (This is a ternary conditional operator)
(Tick the correct option)
(a) if statement written within another if statement is called ______
(ii) nested
(b) Multiple conditions can be checked using ______ statement.
(ii) elif
(c) In while loop, we require a variable known as ______ variable.
(iii) incremental or counter (The options are unclear, but a counter variable is used to
control a while loop)