NCERT Solutions – Exercises
Class 11 Computer Science · Chapter 6 · Flow of Control · Session 2026-27
Question 1
Distinguish between a "for" loop and a "while" loop in Python.
Answer
A "for" loop is typically used when the number of iterations is known in advance (e.g. iterating over a range or a sequence). A "while" loop is typically used when iteration should continue as long as a certain condition remains true, and the number of iterations may not be known beforehand.
Question 2
Write a Python program using a for loop to print numbers from 1 to 5.
Answer
for i in range(1, 6):
print(i)
Output: 1 2 3 4 5 (each printed on a new line).
Question 3
What is the difference between "break" and "continue" statements?
Answer
The "break" statement terminates the loop entirely, jumping to the code after the loop. The "continue" statement only skips the current iteration and moves on to the next iteration of the loop, without terminating the loop itself.
Question 4
Write a Python program to check if a number is even or odd.
Answer
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even")
else:
print("Odd")