Curriculum
Course: Grade XI Computer Science
Login
Text lesson

Le-10 Tuples and Dictionaries

School Revise · Class 11 Computer Science · Chapter 10

Tuples and Dictionaries

Code 083, Class 11. A tuple is a fixed list, and a dictionary stores pairs of keys and values. Here we create and use both.

( )

a tuple

{ }

a dictionary

What this chapter is about

A tuple is an ordered collection like a list, but it cannot be changed (it is immutable). A dictionary stores data as key and value pairs, which we look up by the key.

1. Tuples

Write a tuple in round brackets, separated by commas. Read items by index, just like a list, but you cannot change them.

t = (10, 20, 30) print(t[1]) Output: 20

2. Dictionaries

A dictionary holds key and value pairs in curly brackets. We look up a value by its key, and we can add or change pairs.

d = {“name”: “Ravi”, “age”: 15} print(d[“name”]) Output: Ravi

3. Dictionary methods

keys() gives all the keys, values() gives all the values, items() gives the pairs, and get(key, default) reads a value safely.

Practise with the interactive

Explore the idea by tapping. The interactive opens right here in the lesson.

Try it in the code lab

Write and run real Python right here in the lesson, then work through the practice problems with answers.

Starting Python...

Coding practice problems, with answers

Type each one into the code lab above, then open the card to see the worked solution and its output.

Problem 1. Create a tuple and print it.

SOLUTION

t = (1, 2, 3) print(t)

OUTPUT

(1, 2, 3)
Problem 2. Access a tuple item.

SOLUTION

t = (10, 20, 30) print(t[1])

OUTPUT

20
Problem 3. Find the length of a tuple.

SOLUTION

print(len((1, 2, 3, 4)))

OUTPUT

4
Problem 4. Create a dictionary.

SOLUTION

d = {“name”: “Ravi”, “age”: 15} print(d)

OUTPUT

{‘name’: ‘Ravi’, ‘age’: 15}
Problem 5. Read a value by its key.

SOLUTION

d = {“name”: “Ravi”} print(d[“name”])

OUTPUT

Ravi
Problem 6. Add a new key and value.

SOLUTION

d = {“a”: 1} d[“b”] = 2 print(d)

OUTPUT

{‘a’: 1, ‘b’: 2}
Problem 7. Print all the values.

SOLUTION

d = {“x”: 1, “y”: 2} print(list(d.values()))

OUTPUT

[1, 2]
Problem 8. Loop through a dictionary.

SOLUTION

d = {“a”: 1, “b”: 2} for k in d: print(k, d[k])

OUTPUT

a 1 b 2
Problem 9. Use get with a default value.

SOLUTION

d = {“a”: 1} print(d.get(“z”, 0))

OUTPUT

0
Problem 10. Count the pairs in a dictionary.

SOLUTION

d = {“a”: 1, “b”: 2, “c”: 3} print(len(d))

OUTPUT

3

Practice set A, multiple choice

1. A tuple is written in which brackets?

Round brackets, ( ).

2. Can a tuple be changed after it is made?

No, a tuple is immutable.

3. A dictionary stores data as …

key and value pairs.

4. Which method gives all the keys of a dictionary?

keys().

Quick summary

A tuple is an ordered, immutable collection in round brackets, read by index. A dictionary stores key and value pairs in curly brackets, looked up by key; we can add or change pairs. Methods keys(), values(), items() and get() work with dictionaries.

Open the Virtual Lab

These free Class 11 Computer Science notes explain tuples and dictionaries, creating and accessing them, immutability of tuples, and dictionary methods with worked Python programs and practice, for CBSE students across India and the Gulf including the UAE, Saudi Arabia, Qatar, Oman, Kuwait and Bahrain.

© 2026 School Revise. All rights reserved. Original content aligned to the CBSE and NCERT Class 11 Computer Science syllabus. Unauthorised copying is not permitted.

Layer 1
Login Categories