AmbifulWorksheets
Practice that never repeats
CBSE · Class 9 · Computational Thinking and AI

Python Basics

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.
What does print(7 // 2) display?
  1. 4
  2. 1
  3. 3.5
  4. 3
2.
What does this print?
print(30 * 5 % 6)
  1. 0
  2. 150
  3. 1
  4. −1
3.
What is the data type of the value of len('abc') in Python?
  1. str
  2. float
  3. int
  4. bool
4.
What does this print?
print('ab' + 'na')
  1. abna
  2. naab
  3. ab+na
  4. ab na
5.
What does this print?
x = 14
y = 18
x = x + y
x = x + y
x = x + 5
print(x)
  1. 14
  2. 18
  3. 55
  4. 56
6.
What does this print?
print(12 > 15 and 15 < 14)
  1. False
  2. Error
  3. None
  4. True
7.
What does this print?
print(float(27) + 6)
  1. 34.0
  2. 27.6
  3. 33.0
  4. Error
8.
What does this print?
x = 19
x += 3
x *= 4
x //= 5
print(x)
  1. 18
  2. 88
  3. 17
  4. 22
Section B — Short answer8 × 2 = 16 marks
9.
What is the difference between / and // in Python?
10.
What do these lines print?
print(78 // 4)
print(78 % 4)
Give (a) the first line (b) the second.
11.
What are x and y at the end?
x = 16
y = 17
x = x // 4
x = x // 5
x = x + 5
12.
The user types 53 when this runs. What is printed?
a = input()
print(a * 2)
13.
For x = 4923, what is (a) x % 10 (b) x // 10?
14.
What does this program print?
principal = 3900
rate = 2
time = 2
si = principal * rate * time / 100
print(si)
15.
What does this print?
length = 7
breadth = 23
print(length * breadth)
print(2 * (length + breadth))
Give (a) the first line (b) the second.
16.
What does this print?
m1, m2, m3 = 96, 78, 69
print((m1 + m2 + m3) / 3)
Section C — Word problems4 × 4 = 16 marks
17.
Write a Python program to convert a length in kilometres into metres, and explain each line.
18.
What are the four lines printed?
a = 43
b = 9
print(a // b)
print(a % b)
print(a ** 2)
print(str(a) + str(b))
Give (a) to (d) in order.
19.
What does this program print?
price = 80
discount = 20
off = price * discount / 100
print(off)
print(price - off)
Give (a) the first line (b) the second.
20.
What does this program print?
l, b, h = 6, 13, 9
area = 2 * (l * b + b * h + h * l)
volume = l * b * h
print(area)
print(volume)
Give (a) the area (b) the volume.
AmbifulWorksheets
Practice that never repeats
CBSE · Class 9 · Computational Thinking and AI

Answer key

Python Basics · AW-9CT-PYB-2026-V1 · For parents — fold back or tear off before handing the sheet to your child.

QAnswerWorking
1(d) 3—
2(a) 0Python does ** first, then * / // %, then + and −, left to right
3(c) int—
4(a) abna+ joins two strings
5(c) 55run each line in turn
6(a) Falsework out each comparison, then not, then and, then or
7(c) 33.0int() and float() turn values into numbers
8(c) 1722, 88, 88 // 5 = 17
9/ gives the exact quotient as a float (7 / 2 = 3.5); // gives the whole-number part (7 // 2 = 3).—
10(a) 19; (b) 278 = 4 × 19 + 2
11x = 5, y = 17run each line in turn
125353input() gives text, so * 2 repeats it
13(a) 3; (b) 492% 10 gives the last digit; // 10 removes it
14156.03900 × 2 × 2 ÷ 100; / always gives a float
15(a) 161; (b) 60area, then perimeter
1681.0243 ÷ 3; / gives a float
17km = float(input()) reads the length; m = km * 1000 converts it; print(m) shows the answer.—
18(a) 4; (b) 7; (c) 1849; (d) 43943 = 9 × 4 + 7; str + str joins text
19(a) 16.0; (b) 64.020% of 80 = 16
20(a) 498; (b) 7022 × (78 + 117 + 54); 6 × 13 × 9