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

Getting Started with Python

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.
Python is:
  1. an assembly language
  2. a compiled-only language
  3. a machine language
  4. a high-level, interpreted language
2.
What does this program print?
print((19 + 8) // 6 % 5)
  1. 14
  2. 27
  3. 8
  4. 4
3.
What does this program print?
print(type('9' * 6))
  1. <class 'str'>
  2. <class 'complex'>
  3. <class 'int'>
  4. <class 'dict'>
4.
Which of these is a valid identifier (variable name) in Python?
  1. total item
  2. ScoreName
  3. age.price
  4. area item
5.
Which of these is a keyword in Python?
  1. in
  2. integer
  3. elseif
  4. len
6.
What does this program print?
x = 20
y = 10
x += y
y %= 2
y *= 2
print(x, y)
  1. 30
  2. 30 0
  3. 31 0
  4. 30, 0
7.
What does this program print?
print(56 + int(20 / 6))
  1. 59
  2. 59.333333333333336
  3. 60
  4. Error
8.
What does this program print?
print(19 > 27 or 22 < 27)
  1. Error
  2. True
  3. False
  4. 22
Section B — Short answer8 × 2 = 16 marks
9.
Name the five kinds of Python tokens with an example of each.
10.
What does this program print? Give (a) the first line (b) the second.
a = 23
b = 1 - 23
print(a // b)
print(a % b)
11.
What are the values of x and y after these lines run?
x, y = 3, 8
y = y + x // 3
x, y = y, x + y
x, y = y, x
12.
The user types 34 and then 33 when this program runs. What is printed?
a = int(input())
b = int(input())
print(a + b)
13.
This program is meant to subtract 2 from x until it is at most 2. What kind of error does it have: a syntax error, a runtime error or a logical error?
x = 65
while x > 2
    x = x - 2
print(x)
14.
Which of these statements are NOT valid in Python? Write their letters.
(a) total * 2 = 18
(b) total = x + 16
(c) total += 16
(d) 'total' = 16
15.
What does this program print? Give (a) the first line (b) the second.
a, b, c = 8, 57, 2
print(a, b, c, sep='*')
print(a, end='#')
print(b)
16.
What does this program print? Give (a) the first line (b) the second.
print(6 + 9.0)
print(False * 6 + 9)
Section C — Word problems4 × 4 = 16 marks
17.
Explain the data types of Python with an example of each: number, boolean, sequence, None and mapping.
18.
What does this program print? Give the four lines (a) to (d).
a = 10
b = 9
print(a // b)
print(a % b)
print(a ** 2)
print(str(a) + str(b))
19.
The user types 74, then 99, then 93. What does this program print? Give the three lines (a) to (c).
a = int(input())
b = int(input())
c = int(input())
total = a + b + c
print(total)
print(total / 3)
print(total / 3 >= 75)
20.
This program should print the area and perimeter of a rectangle (the user types 8 and 15), but one line has an error.
length = int(input()) # line 1
breadth = int(input()) # line 2
area = length * breadth # line 3
perimeter = 2 * (length + breadth) # line 4
print('Area: ' + area) # line 5
print('Perimeter:', perimeter) # line 6
(a) Which line has the error? (b) Is it a syntax, runtime or logical error? (c) Write the corrected line. (d) What does the corrected program print?
AmbifulWorksheets
Practice that never repeats
CBSE · Class 11 · Computer Science

Answer key

Getting Started with Python · AW-11CS-PYB-2026-V1 · For parents — fold back or tear off before handing the sheet to your child.

QAnswerWorking
1(d) a high-level, interpreted language—
2(d) 4brackets first, then // and % from left to right
3(a) <class 'str'>the value is of type str
4(b) ScoreNamestarts with a letter or _, then letters, digits or _ only, and is not a keyword
5(a) inin is reserved by Python
6(b) 30 0run each line in turn; x //= k floors towards minus infinity
7(a) 59int() drops the fraction of the quotient
8(b) Trueor is true if either comparison is true
9Keywords (if), identifiers (marks), literals (25, 'hi'), operators (+, ==) and punctuators (:, (, ,).—
10(a) −2; (b) −21a = 23, b = −22: // rounds down (towards minus infinity), and a = b × (a // b) + a % b
11x = 12, y = 9in x, y = …, both right-hand values are worked out before either name changes
1267both are converted to int first
13syntax errorPython refuses to run it: a rule of the language is broken
14a, dthe left side of = must be a name (an l-value), not a value or an expression
15(a) 8*57*2; (b) 8#57sep goes between the values; end replaces the newline
16(a) 15.0; (b) 9an int mixed with a float becomes a float; True counts as 1 and False as 0
17Numbers: int 25, float 2.5, complex 3 + 2j; bool True; sequences: str 'hi', list [1, 2], tuple (1, 2); None; mapping: dict {'a': 1}.—
18(a) 1; (b) 1; (c) 100; (d) 10910 = 9 × 1 + 1; str + str joins text
19(a) 266; (b) 88.66666666666667; (c) True266 ÷ 3; / always gives a float
20(a) line 5; (b) runtime error; (c) print('Area:', area); (d) Area: 120 / Perimeter: 46it stops with TypeError