Curriculum
Course: Grade XI Informatics Practices
Login
Text lesson

Ch4-Lists-and-Dictionaries-in-Python

School Revise · Class 11 Informatics Practices · Chapter 4

Lists and Dictionaries in Python

Code 065, Class 11. A list holds many values in order; a dictionary stores key and value pairs. Here we create and use both.

[]

a list

{ }

a dictionary

What this chapter is about

A list stores several ordered values and can be changed. A dictionary stores key and value pairs, looked up by the key.

1. Lists

Write a list in square brackets. append() adds, remove() deletes, sort() orders, and len(), sum(), max() work on it.

nums = [10, 20, 30] nums.append(40) print(nums) Output: [10, 20, 30, 40]

2. Dictionaries

A dictionary holds key and value pairs in curly brackets. Look up a value with d[“key”], and add a pair with d[“new”] = value.

3. Working with both

You can loop through a list with for, and through a dictionary to read its keys and values. Both are widely used to hold data.

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 list and print it.

SOLUTION

nums = [10, 20, 30] print(nums)

OUTPUT

[10, 20, 30]
Problem 2. Append an item to a list.

SOLUTION

nums = [1, 2] nums.append(3) print(nums)

OUTPUT

[1, 2, 3]
Problem 3. Find the sum of a list.

SOLUTION

print(sum([2, 4, 6]))

OUTPUT

12
Problem 4. Sort a list.

SOLUTION

nums = [3, 1, 2] nums.sort() print(nums)

OUTPUT

[1, 2, 3]
Problem 5. Loop through a list.

SOLUTION

for x in [1, 2, 3]: print(x)

OUTPUT

1 2 3
Problem 6. Create a dictionary.

SOLUTION

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

OUTPUT

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

SOLUTION

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

OUTPUT

Ravi
Problem 8. Add a key and value.

SOLUTION

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

OUTPUT

{‘a’: 1, ‘b’: 2}
Problem 9. Print all the keys.

SOLUTION

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

OUTPUT

[‘x’, ‘y’]
Problem 10. Loop through a dictionary.

SOLUTION

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

OUTPUT

a 1 b 2

Practice set A, multiple choice

1. A list is written inside which brackets?

Square brackets, [ ].

2. Which method adds to a list?

append().

3. A dictionary stores data as …

key and value pairs.

4. How do you read a dictionary value?

With d[“key”].

Quick summary

A list stores ordered values in square brackets and is mutable; append(), remove() and sort() change it, and len(), sum(), max() work on it. A dictionary stores key and value pairs in curly brackets, read by key and extended with d[“new”] = value. Both can be looped through.

Open the Virtual Lab

These free Class 11 Informatics Practices notes explain lists and dictionaries, list methods, dictionary key and value pairs, and looping through them with worked examples 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 Informatics Practices syllabus. Unauthorised copying is not permitted.

Layer 1
Login Categories