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

Tuples and Dictionaries

Standard difficulty · 20 questions · 40 marks · Time: 38 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 tuple is:
  1. a set of key–value pairs
  2. an unordered collection
  3. a sequence that can be changed in place
  4. an ordered sequence that cannot be changed after it is made
2.
What does this program print?
t = (57, 15, 39, 40, 36, 27)
print(t[4:6])
  1. [36, 27]
  2. 36
  3. (27, 36)
  4. (36, 27)
3.
What does this program print?
t = (52,)
print(t * 2)
  1. [52, 52]
  2. (52, 52)
  3. 104
  4. (52,)
4.
What happens when this program runs?
t = (47, 22, 6)
a, b = t
print(a, b)
  1. it prints 47 (22, 6)
  2. it prints (47, 22, 6)
  3. it stops with a ValueError: there are 3 values but only 2 names
  4. it prints 47 22
5.
What happens when this program runs?
d = {'apple': 59, 'plum': 16, 'peach': 56, 'grape': 79}
print(d['mango'])
  1. it stops with a KeyError, because 'mango' is not a key
  2. it prints None
  3. it prints 'mango'
  4. it prints 0
6.
What does this program print?
d = {'peach': 78, 'melon': 33, 'apple': 21}
d.update({'apple': 93, 'plum': 94})
print(d)
  1. None
  2. {'peach': 78, 'melon': 33, 'apple': 21, 'plum': 94}
  3. {'apple': 93, 'plum': 94}
  4. {'peach': 78, 'melon': 33, 'apple': 93, 'plum': 94}
7.
What does this program print?
d = {'lemon': 20, 'kiwi': 85, 'melon': 94, 'mango': 63}
del d['melon']
print(len(d), 'melon' in d)
  1. 3 False
  2. 4 True
  3. None False
  4. 3 True
8.
What does this program print?
s = 'letter'
d = {}
for ch in s:
    d[ch] = d.get(ch, 0) + 1
print(d['t'], len(d))
  1. 2 4
  2. 4 2
  3. 2 6
  4. 1 4
Section B — Short answer8 × 2 = 16 marks
9.
Give two differences between a list and a tuple.
10.
What does this program print? Give (a) the first line (b) the second.
t1 = (26, 17)
t2 = (42, 37)
print(t1 + t2)
print(len(t1 * 2 + t2))
11.
What does this program print?
d = {'pear': 70, 'lemon': 68, 'peach': 60}
d['plum'] = 89
d['pear'] = d['pear'] + 10
del d['peach']
print(d)
12.
What does this program print? Give (a) the first line (b) the second.
d = {'plum': 93, 'lemon': 70, 'mango': 38, 'grape': 62}
print(d.get('lemon', 7))
print(d.get('guava', 7))
13.
What does this program print? Give (a) the first line (b) the second (c) the third.
s = 'banana'
d = {}
for ch in s:
    if ch in d:
        d[ch] = d[ch] + 1
    else:
        d[ch] = 1
print(d['n'])
print(len(d))
print(max(d.values()))
14.
What does this program print? Give (a) the first line (b) the second.
salary = {'Priya': 41000, 'Vikram': 24000, 'Arjun': 43000, 'Rohan': 15000, 'Kabir': 20000}
total = 0
count = 0
for name in salary:
    total = total + salary[name]
    if salary[name] > 25000:
        count = count + 1
print(total)
print(count)
15.
What does this program print? Give (a) the first line (b) the second (c) the third.
t = ((15, 19), (47, 59, 56), (62,))
print(t[1][2])
print(len(t[2]))
print(t[0] + t[2])
16.
What does this program print?
marks = {'history': 47, 'english': 79, 'music': 42}
print(marks.items())
Section C — Word problems4 × 4 = 16 marks
17.
Write a program to make a dictionary of employees and their salaries, and print the names of those earning more than a given amount.
18.
What does this program print? Give the four lines (a) to (d).
marks = {'hindi': 49, 'music': 40, 'history': 60}
print(len(marks))
marks['art'] = 84
print(sum(marks.values()))
print(marks.pop('hindi'))
print(sorted(marks))
19.
This program stores the roll number, name and marks of 5 students. Write the names it prints, in order.
d = {1: ['Rahul', 87], 2: ['Meera', 58], 3: ['Ananya', 88], 4: ['Kabir', 94], 5: ['Vikram', 82]}
for roll in d:
    if d[roll][1] > 75:
        print(d[roll][0])
20.
What does this program print? Give the three lines (a) to (c).
t = (20, 63, 95, 30, 27, 85, 95)
print(min(t), max(t))
print(sum(t) / len(t))
print(t.count(95), t.index(95))
AmbifulWorksheets
Practice that never repeats
CBSE · Class 11 · Computer Science

Answer key

Tuples and Dictionaries · AW-11CS-TDC-2026-V1 · For parents — fold back or tear off before handing the sheet to your child.

QAnswerWorking
1(d) an ordered sequence that cannot be changed after it is made—
2(d) (36, 27)a slice of a tuple is a tuple; a one-item tuple prints with a comma
3(b) (52, 52)* repeats the tuple
4(c) it stops with a ValueError: there are 3 values but only 2 namesthe number of names must equal the number of values
5(a) it stops with a KeyError, because 'mango' is not a keyuse get() to avoid the error
6(d) {'peach': 78, 'melon': 33, 'apple': 93, 'plum': 94}update() changes an existing key in place and adds a new one at the end
7(a) 3 Falsedel removes the key and its value
8(a) 2 4each letter is a key; 't' appears 2 times and there are 4 different letters
9A list is mutable and written in [ ]; a tuple is immutable and written in ( ); tuples can be dictionary keys and are a little faster.—
10(a) (26, 17, 42, 37); (b) 6+ joins tuples into a new tuple; * repeats
11{'pear': 80, 'lemon': 68, 'plum': 89}a new key goes at the end; changing a value keeps its place
12(a) 70; (b) 7'lemon' is a key; 'guava' is not, so the default 7 is given
13(a) 2; (b) 3; (c) 3counts: b 1, a 3, n 2
14(a) 143000; (b) 241000 + 24000 + 43000 + 15000 + 20000; salaries above 25000
15(a) 56; (b) 1; (c) (15, 19, 62)t[2] is a one-item tuple; + joins tuples
16dict_items([('history', 47), ('english', 79), ('music', 42)])items() gives (key, value) tuples in a dict_items view
17sal = {'Asha': 30000, …}; for name in sal: if sal[name] > limit: print(name).—
18(a) 3; (b) 233; (c) 49; (d) ['art', 'history', 'music']each line uses the dictionary as the lines before left it
19Rahul, Ananya, Kabir, Vikrammarks above 75: Rahul 87, Ananya 88, Kabir 94, Vikram 82
20(a) 20 95; (b) 59.285714285714285; (c) 2 295 appears twice; index() gives the first position