AmbifulWorksheets
Practice that never repeats
CBSE · Class 11 · Computer Science

Flow of Control

Standard difficulty · 20 questions · 40 marks · Time: 40 minutes

Name: Date: Score: ____ / 40

Show your working for Sections B and C. Answers are on the last page — try every question first!

Section A — Choose the correct answer8 × 1 = 8 marks
1.
In Python, the statements inside an if block are marked by:
  1. the keyword end
  2. semicolons
  3. curly brackets
  4. indentation
2.
What does this program print?
temp = 41
if temp < 20:
    print('cold')
elif temp <= 34:
    print('pleasant')
else:
    print('hot')
  1. hot
  2. cold
  3. pleasant
  4. cold pleasant
3.
What does this program print?
s = 0
for i in range(7):
    s = s + i
print(s)
  1. 15
  2. 28
  3. 21
  4. 22
4.
What does this program print?
n = 367
count = 0
while n > 4:
    n = n // 2
    count = count + 1
print(count, n)
  1. 7 4
  2. 7 2
  3. 6 2
  4. 8 1
5.
What does this program print?
print(list(range(1, 20, 4)))
  1. [2, 6, 10, 14, 18]
  2. [5, 9, 13, 17, 21]
  3. [5, 9, 13, 17]
  4. [1, 5, 9, 13, 17]
6.
What does this program print?
for i in range(1, 30):
    if i * i > 246:
        break
print(i)
  1. 15
  2. 256
  3. 16
  4. 17
7.
What does this program print?
c = 0
for i in range(7):
    for j in range(i, 7):
        c = c + 1
print(c)
  1. 28
  2. 35
  3. 27
  4. 29
8.
This program should print 1 + 2 + … + 21 = 231, but it prints 21. Which change fixes it?
s = 0
for i in range(1, 22):
    s = s + 1
print(s)
  1. s = s + i should be s = s * i
  2. change print(s) to print(i)
  3. change s = s + 1 to s = s + i
  4. change range(1, 21) to range(1, 22)
Section B — Short answer8 × 2 = 16 marks
9.
What is the difference between break and continue?
10.
What does this program print?
s = 0
for i in range(6, 12):
    s = s + i * i
print(s)
11.
What does this program print?
x = 9
while x < 987:
    x = x * 9
print(x)
12.
What does this program print?
x = 54
if x > 38:
    if x % 2 == 0:
        print('large even')
    else:
        print('large odd')
else:
    print('small')
13.
What is printed on line 4 of the output?
for i in range(1, 5):
    for j in range(i):
        print(chr(65 + j), end='')
    print()
14.
What does this program print?
n = 7
f = 1
for i in range(1, n + 1):
    f = f * i
print(f)
15.
What does this program print? Give (a) the first number printed (b) the second.
n = 23
count = 0
while True:
    n = n + 7
    count = count + 1
    if n % 6 == 0:
        break
print(n, count)
16.
What are a, b and c after these lines run?
a, b, c = 72, 52, 86
if a > b:
    a, b = b, a
if b > c:
    b, c = c, b
if a > b:
    a, b = b, a
Section C — Word problems4 × 4 = 16 marks
17.
Explain the if, if-else and if-elif-else statements with a flowchart idea and a program for each.
18.
Trace this code.
i = 4
s = 0
while i <= 24:
    if i % 7 == 0:
        s = s + i
    i = i + 4
(a) What is s at the end? (b) What is i at the end? (c) How many times does the loop body run?
19.
What does this program print when the user types (a) 45354 (b) 35363?
n = int(input())
r = 0
t = n
while t > 0:
    r = r * 10 + t % 10
    t = t // 10
if r == n:
    print('Palindrome')
else:
    print('Not a palindrome')
20.
Write the numbers this program prints, in order.
n = 10
a, b = 0, 1
for i in range(n):
    print(a)
    a, b = b, a + b
AmbifulWorksheets
Practice that never repeats
CBSE · Class 11 · Computer Science

Answer key

Flow of Control · AW-11CS-FLC-2026-V1 · For parents — fold back or tear off before handing the sheet to your child.

QAnswerWorking
1(d) indentation—
2(a) hot41: the first true condition wins
3(c) 21i takes 0, 1, 2, 3, 4, 5, 6 (the stop value 7 is not included)
4(b) 7 2n ends at 2 after 7 passes
5(d) [1, 5, 9, 13, 17]start at 1, add 4, stop before 20
6(c) 1616 × 16 = 256 is the first square above 246
7(a) 28count the passes of the inner loop for each i
8(c) change s = s + 1 to s = s + iit adds 1 each time instead of i
9break leaves the loop completely; continue skips the rest of the current pass and starts the next one.—
10451i = 6, 7, 8, 9, 10, 11
1165619 → 81 → 729 → 6561
12large even54 > 38 is true
13ABCDline 4 has the first 4 capital letters
1450401 × 2 × 3 × 4 × 5 × 6 × 7
15(a) 30; (b) 1the loop stops at the first multiple of 6
16a = 52, b = 72, c = 86each swap puts the smaller value first: the three numbers end up sorted
17if runs a block when a condition is True; if-else chooses one of two blocks; if-elif-else checks conditions in turn, e.g. grades from marks.—
18(a) 0; (b) 28; (c) 6i: 4, 8, 12, 16, 20, 24; multiples of 7 added
19(a) Palindrome; (b) Not a palindromeit compares n with the digits reversed
200, 1, 1, 2, 3, 5, 8, 13, 21, 34each term is the sum of the two before it