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

Python Modules: math, random and statistics

Standard difficulty · 20 questions · 40 marks · Time: 37 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.
A module in Python is:
  1. a data type
  2. an error message
  3. a kind of loop
  4. a file of Python definitions that can be imported and used
2.
What does this program print?
import math
print(math.ceil(159 / 8))
  1. 22
  2. 40
  3. 20
  4. 21
3.
Which of these can this program NEVER print?
import random
print(random.randint(20, 24))
  1. 25
  2. 23
  3. 20
  4. 24
4.
What does this program print?
import statistics
data = [13, 12, 24, 17, 26, 17, 30]
print(statistics.median(data))
  1. 16
  2. 17.0
  3. 18
  4. 17
5.
What does this program print?
import math
print(math.ceil(67 / 7), math.floor(67 / 7), 67 // 7)
  1. 10.0 9.0 9
  2. 10 9 10
  3. 9 10 9
  4. 10 9 9
6.
After the statement import math, which of these runs without an error?
  1. print(fabs(18.5))
  2. print(math.fabs[18.5])
  3. print(math.fabs(18.5))
  4. print(math(fabs(18.5)))
7.
How many different values can this program print?
import random
print(random.randrange(8, 25, 2))
  1. 10
  2. 17
  3. 9
  4. 8
8.
What is the largest value this program can print?
import random
x = int(random.random() * 17) + 11
print(x)
  1. 27
  2. 28
  3. 16
  4. 17
Section B — Short answer8 × 2 = 16 marks
9.
What is the difference between import math and from math import sqrt?
10.
What does this program print? Give (a) the first line (b) the second.
import math
print(math.floor(8.5 - 17))
print(math.pow(2, 3))
11.
What does this program print? Give the three lines (a) to (c).
import statistics as st
data = [29, 5, 21, 20, 20]
print(st.mean(data))
print(st.median(data))
print(st.mode(data))
12.
What are (a) the smallest (b) the largest values this program can print?
import random
x = random.randint(3, 12) * 5 + 8
print(x)
13.
What does this program print? Give (a) the first line (b) the second.
import math
a, b = 80, 84
c = math.sqrt(a ** 2 + b ** 2)
print(c)
print(int(math.sqrt(121)))
14.
What does this program print?
import math
print(math.pow(2, 2) + math.fabs(11 - 22))
15.
274 students go on a trip in buses of 56 seats. What does this program print? Give (a) the first line (b) the second.
from math import ceil
students = 274
seats = 56
buses = ceil(students / seats)
print(buses)
print(buses * seats - students)
16.
What does this program print? Give (a) the first line (b) the second.
import math
r = 5
print(math.floor(math.pi * r * r))
print(math.ceil(2 * math.pi * r))
Section C — Word problems4 × 4 = 16 marks
17.
Explain three ways of importing a module and using its functions, with examples.
18.
The user types 30. What does this program print? Give the three lines (a) to (c).
import math
r = int(input())
area = math.pi * r ** 2
circ = 2 * math.pi * r
print(math.floor(area))
print(math.ceil(circ))
print(math.sqrt(r * r))
19.
What does this program print? Give the three lines (a) to (c).
from statistics import mean, median, mode
scores = [27, 14, 30, 14, 6, 24, 15]
print(mean(scores))
print(median(scores))
print(mode(scores))
20.
This program throws two dice, one with 7 faces and one with 5.
import random
a = random.randint(1, 7)
b = random.randint(1, 5)
print(a + b)
(a) What is the smallest total it can print? (b) The largest? (c) How many different totals can it print?
AmbifulWorksheets
Practice that never repeats
CBSE · Class 11 · Computer Science

Answer key

Python Modules: math, random and statistics · AW-11CS-MOD-2026-V1 · For parents — fold back or tear off before handing the sheet to your child.

QAnswerWorking
1(d) a file of Python definitions that can be imported and used—
2(c) 20ceil() rounds up to a whole number (an int)
3(a) 25randint(20, 24) gives a whole number from 20 to 24, both included
4(d) 17sorted: 12, 13, 17, 17, 24, 26, 30
5(d) 10 9 967 / 7 = 9.571428571428571
6(c) print(math.fabs(18.5))import math brings in the module; each function is used as math.fabs(…)
7(c) 9the values are 8, 10, 12, 14, 16, 18, 20, 22, 24
8(a) 27random() gives 0 ≤ r < 1, so int(r × 17) is 0 to 16
9import math brings in the module, so functions are used as math.sqrt(); from math import sqrt brings in only sqrt, used directly as sqrt().—
10(a) −9; (b) 8.08.5 − 17 = −8.5; floor() goes down, to the more negative whole number; pow() always gives a float
11(a) 19; (b) 20; (c) 20sum 95 ÷ 5; sorted: 5, 20, 20, 21, 29; mean of whole numbers prints without .0 only when it is exact, and the median of an even count is a float
12(a) 23; (b) 683 × 5 + 8 and 12 × 5 + 8
13(a) 116.0; (b) 11802 + 842 = 13456; int() drops the fraction of √121
1415.04.0 + 11.0: both give floats
15(a) 5; (b) 6274 ÷ 56 ≈ 4.89, rounded up; then the empty seats
16(a) 78; (b) 32π × 5 × 5 ≈ 78.54; 2 × π × 5 ≈ 31.42
17import math → math.sqrt(9); from math import sqrt → sqrt(9); from math import * → sqrt(9) and pi; import math as m → m.sqrt(9).—
18(a) 2827; (b) 189; (c) 30.0area ≈ 2827.43, circumference ≈ 188.5; sqrt() gives a float
19(a) 18.571428571428573; (b) 15; (c) 14sum 130 ÷ 7; sorted: 6, 14, 14, 15, 24, 27, 30; 14 is the most common
20(a) 2; (b) 12; (c) 11totals run from 1 + 1 to 7 + 5, every whole number in between