CH 8 – Control Flow Statements
Maximum Marks: 40
Section A: Multiple Choice Questions (1 mark each)
1. Which of the following is a conditional statement in Python?
a) def b) while c) if d) for
2. The else part of an if statement executes when:
a) The condition is True
b) The condition is False
c) There is an error
d) It is inside a loop
3. What will be the output of the following code?
x=5
if x > 2:
print("Hi")
else:
print("Bye")
a) No output b) Error c) Bye d) Hi
4. Which keyword is used to skip the rest of the code inside a loop for the current iteration?
a) exit b) pass c) continue d) break
5. Which statement is used to exit a loop prematurely?
a) pass b) break c) quit d) stop
6. How many times will the following loop execute?
for i in range(3):
print(i)
a) Infinite b) 4 c) 3 d) 2
7. What is the output of the following code?
x=0
while x < 3:
print(x)
x += 1
a) Infinite loop b) 0 1 2 3 c) 1 2 3 d) 0 1 2
8. The pass statement is used to:
a) Stop loop execution b) Do nothing and move to the next statement
c) Skip the current iteration d) Raise an error
9. Which of the following is an example of nested control flow?
a) if inside a for loop b) Two separate if statements
c) Loop after a condition d) Function call
10. What is the output of:
for i in range(1, 6, 2):
print(i)
a) 0 2 4 b) 2 4 6 c) 1 3 5 d) 1 2 3 4 5
11. What is the output of:
x = 10
if x > 10:
print("A")
elif x == 10:
print("B")
else:
print("C")
a) Error b) C c) B d) A
Section B: Short Answer Questions (2 marks each) (Any 4 questions)
12. What is the difference between break and continue statements in Python?
13. Write a Python program to check whether a number is even or odd.
14. Write the output of the following code:
x = 10
if x % 2 == 0:
print("Even")
else:
print("Odd")
15. Write a Python statement that prints all numbers from 1 to 5 using a for loop.
16. Explain the role of the else clause in a loop with an example.
Section C: Short Answer Questions (3 marks each) (Any 3 questions)
17. Write a Python program that accepts a number and prints whether it is positive, negative, or zero.
18. Predict the output of the following code:
for i in range(1, 6):
if i == 3:
continue
print(i)
19. Write a Python program to print the sum of all even numbers between 1 and 10 using a while loop.
20. Differentiate between for and while loops with suitable examples.
Section D: Long Answer Questions (5 marks each)
21. Write a Python program to find the factorial of a number using a for loop.
22. Write a Python program that displays the multiplication table of a number entered by the user, up to 10,
using a loop.
ANSWER KEY
Section A
1. c) if
2. b) The condition is False
3. d) Hi
4. c) continue
5. b) break
6. c) 3
7. d) 0 1 2
8. b) Do nothing and move to the next statement
9. a) if inside a for loop
10. c) 1 3 5
11. c) B
Section B
12.
break exits the loop immediately.
continue skips the remaining code in the current iteration and moves to the next iteration.
13.
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even")
else:
print("Odd")
14. Output: Even
15. for i in range(1, 6):
print(i)
16. The else in a loop executes only when the loop completes normally (without break).
Example:
for i in range(3):
print(i)
else:
print("Done")
Section C
17.
n = int(input("Enter a number: "))
if n > 0:
print("Positive")
elif n < 0:
print("Negative")
else:
print("Zero")
18. Output:
1
2
4
5
19.
i=1
total = 0
while i <= 10:
if i % 2 == 0:
total += i
i += 1
print("Sum =", total)
Output → Sum = 30
20.
for loop: used when the number of iterations is known.
while loop: used when the number of iterations is not fixed.
Example:
for i in range(5): print(i)
while condition: print(i)
Section D
21. num = int(input("Enter a number: "))
fact = 1
for i in range(1, num + 1):
fact *= i
print("Factorial =", fact)
22.
n = int(input("Enter a number: "))
for i in range(1, 11):
print(n, "x", i, "=", n * i)