Skip to main content
Chapter 4 of 8
NCERT Solutions

Working with Lists and Dictionaries — NCERT Solutions

CBSE · Class 11 · Informatics Practices

NCERT question answers for Working with Lists and Dictionaries, CBSE Class 11 Informatics Practices: 44 textbook questions solved step by step.

94 questions72 flashcards5 formulas & key relations5 concepts

Interactive on Super Tutor

Studying Working with Lists and Dictionaries? Get the full interactive chapter.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for NCERT solutions and more.

Free trial, no card needed.

44 Questions Solved · 1 Section

The first 22 solutions are open to read. The other 22 are free with a Super Tutor account. Unlock all 44 free in Super Tutor

Exercise

1(a)list1 = [12, 32, 65, 26, 80, 10]
list1.sort()
print(list1)
Show solution

sort() changes the list in place and arranges the elements in ascending order.

So after sorting:

  • original list: [12, 32, 65, 26, 80, 10]
  • sorted list: [10, 12, 26, 32, 65, 80]

print(list1) displays that sorted list.

Not sure why a step works? check your working in Super Tutor

1(b)list1 = [12, 32, 65, 26, 80, 10]
sorted(list1)
print(list1)
Show solution

sorted(list1) creates a new sorted list but does not change list1.

So list1 remains the same:

[12, 32, 65, 26, 80, 10]

Not sure why a step works? check your working in Super Tutor

1(c)list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list1[::-2]
list1[:3] + list1[3:]
Show solution
  • list1[::-2] takes the list in reverse order with step size 2, so it gives elements at positions 9, 7, 5, 3, 1.
  • Result: [10, 9, 8, 7, 6]
  • list1[:3] + list1[3:] joins the first 3 elements and the remaining elements.
  • list1[:3] = [1, 2, 3]
  • list1[3:] = [4, 5, 6, 7, 8, 9, 10]
  • Combined result: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Not sure why a step works? check your working in Super Tutor

1(d)list1 = [1, 2, 3, 4, 5]
list1[len(list1)-1]
Show solution

len(list1) = 5, so len(list1)-1 = 4.

list1[4] is the last element of the list, which is 5.

Not sure why a step works? check your working in Super Tutor

2(a)myList.append([50, 60])

myList = [10, 20, 30, 40]
a) myList.append([50, 60])
b) myList.extend([80, 90])

Show solution

append() adds one element to the end of the list. Here the whole list [50, 60] is appended as a single nested list.

So myList becomes:

[10, 20, 30, 40, [50, 60]]

Not sure why a step works? check your working in Super Tutor

2(b)myList.extend([80, 90])

myList = [10, 20, 30, 40]
a) myList.append([50, 60])
b) myList.extend([80, 90])

Show solution

extend() adds each element of the given list to the end of the existing list.

So [80, 90] is added element by element:

[10, 20, 30, 40, 80, 90]

Not sure why a step works? check your working in Super Tutor

3myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for i in range(0, len(myList)):
if i%2 == 0:
print(myList[i])
Show solution

The loop runs through all indices from 0 to 9. It prints the element only when i % 2 == 0, i.e. for even indices:

  • i=0 → 1
  • i=2 → 3
  • i=4 → 5
  • i=6 → 7
  • i=8 → 9

So the output is:

1
3
5
7
9

Not sure why a step works? check your working in Super Tutor

4(a)myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
del myList[3:]
print(myList)
Show solution

del myList[3:] deletes all elements from index 3 to the end.

Starting list:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

After deletion, the remaining list is:
[1, 2, 3]

Not sure why a step works? check your working in Super Tutor

4(b)myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
del myList[:5]
print(myList)
Show solution

del myList[:5] deletes elements from the start up to index 4.

So from:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

the remaining list is:
[6, 7, 8, 9, 10]

Not sure why a step works? check your working in Super Tutor

4(c)myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
del myList[::2]
print(myList)
Show solution

del myList[::2] deletes every second element starting from index 0.

So elements at indices 0, 2, 4, 6, 8 are removed:

  • removed: 1, 3, 5, 7, 9
  • remaining: 2, 4, 6, 8, 10

Final list:
[2, 4, 6, 8, 10]

Not sure why a step works? check your working in Super Tutor

5Differentiate between append() and extend() methods of list.Show solution

append() adds its argument as a single element at the end of the list.

extend() adds each element of the given list/iterable separately to the end of the list.

Example:

  • myList.append([50, 60]) → [..., [50, 60]]
  • myList.extend([50, 60]) → [..., 50, 60]

Not sure why a step works? check your working in Super Tutor

6(a)list1 * 2

Consider a list:

list1 = [6, 7, 8, 9]

What is the difference between the following operations on list1:

a) list1 * 2
b) list1 *= 2
c) list1 = list1 * 2

Show solution

list1 * 2 means the list is repeated twice. It creates a new list and does not change the original list.

So:
[6, 7, 8, 9] * 2 = [6, 7, 8, 9, 6, 7, 8, 9]

Not sure why a step works? check your working in Super Tutor

6(b)list1 *= 2

Consider a list:

list1 = [6, 7, 8, 9]

What is the difference between the following operations on list1:

a) list1 * 2
b) list1 *= 2
c) list1 = list1 * 2

Show solution

list1 *= 2 is the in-place repetition form. It changes list1 itself by repeating its elements twice.

So after the operation, list1 becomes:
[6, 7, 8, 9, 6, 7, 8, 9]

Not sure why a step works? check your working in Super Tutor

6(c)list1 = list1 * 2

Consider a list:

list1 = [6, 7, 8, 9]

What is the difference between the following operations on list1:

a) list1 * 2
b) list1 *= 2
c) list1 = list1 * 2

Show solution

list1 = list1 * 2 assigns the repeated list back to list1. So it also makes list1 contain the elements twice.

Result:
[6, 7, 8, 9, 6, 7, 8, 9]

Not sure why a step works? check your working in Super Tutor

7(a)Percentage of the student

The record of a student (Name, Roll No, Marks in five subjects and percentage of marks) is stored in the following list:

stRecord = ['Raman', 'A-36', [56, 98, 99, 72, 69],
78.8]

Write Python statements to retrieve the following information from the list stRecord.

a) Percentage of the student
b) Marks in the fifth subject
c) Maximum marks of the student
d) Roll No. of the student
e) Change the name of the student from 'Raman' to 'Raghav'

Show solution

In stRecord = ['Raman', 'A-36', [56, 98, 99, 72, 69], 78.8], the percentage is the last element of the list.

So the statement is:
stRecord[3]

This gives 78.8.

Not sure why a step works? check your working in Super Tutor

7(b)Marks in the fifth subject

The record of a student (Name, Roll No, Marks in five subjects and percentage of marks) is stored in the following list:

stRecord = ['Raman', 'A-36', [56, 98, 99, 72, 69],
78.8]

Write Python statements to retrieve the following information from the list stRecord.

a) Percentage of the student
b) Marks in the fifth subject
c) Maximum marks of the student
d) Roll No. of the student
e) Change the name of the student from 'Raman' to 'Raghav'

Show solution

The marks of the five subjects are stored as the nested list stRecord[2] = [56, 98, 99, 72, 69].

The fifth subject is at index 4 of that inner list.

So the required statement is:
stRecord[2][4]

This gives 69.

Not sure why a step works? check your working in Super Tutor

7(c)Maximum marks of the student

The record of a student (Name, Roll No, Marks in five subjects and percentage of marks) is stored in the following list:

stRecord = ['Raman', 'A-36', [56, 98, 99, 72, 69],
78.8]

Write Python statements to retrieve the following information from the list stRecord.

a) Percentage of the student
b) Marks in the fifth subject
c) Maximum marks of the student
d) Roll No. of the student
e) Change the name of the student from 'Raman' to 'Raghav'

Show solution

The subject marks list is stRecord[2] = [56, 98, 99, 72, 69].

The maximum marks can be obtained using max():

max(stRecord[2])

Now:
max([56, 98, 99, 72, 69]) = 99

Not sure why a step works? check your working in Super Tutor

7(d)Roll No. of the student

The record of a student (Name, Roll No, Marks in five subjects and percentage of marks) is stored in the following list:

stRecord = ['Raman', 'A-36', [56, 98, 99, 72, 69],
78.8]

Write Python statements to retrieve the following information from the list stRecord.

a) Percentage of the student
b) Marks in the fifth subject
c) Maximum marks of the student
d) Roll No. of the student
e) Change the name of the student from 'Raman' to 'Raghav'

Show solution

The roll number is the second element of the list stRecord.

So the required statement is:
stRecord[1]

This gives A-36.

Not sure why a step works? check your working in Super Tutor

7(e)Change the name of the student from 'Raman' to 'Raghav'

The record of a student (Name, Roll No, Marks in five subjects and percentage of marks) is stored in the following list:

stRecord = ['Raman', 'A-36', [56, 98, 99, 72, 69],
78.8]

Write Python statements to retrieve the following information from the list stRecord.

a) Percentage of the student
b) Marks in the fifth subject
c) Maximum marks of the student
d) Roll No. of the student
e) Change the name of the student from 'Raman' to 'Raghav'

Show solution

The first element of the list stores the student's name. To change 'Raman' to 'Raghav', overwrite the first element:

stRecord[0] = 'Raghav'

After this assignment, the name in the list is updated.

Not sure why a step works? check your working in Super Tutor

8(a)print(stateCapital.get("Bihar"))

stateCapital = {"Assam":"Guwahati",
"Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}

Find the output of the following statements:

a) print(stateCapital.get("Bihar"))
b) print(stateCapital.keys())
c) print(stateCapital.values())
d) print(stateCapital.items())
e) print(len(stateCapital))
f) print("Maharashtra" in stateCapital)
g) print(stateCapital.get("Assam"))
h) del stateCapital["Assam"]
print(stateCapital)

Show solution

stateCapital.get("Bihar") returns the value mapped to the key Bihar. In the given dictionary, Bihar maps to Patna.

So the output is:

Patna

Not sure why a step works? check your working in Super Tutor

8(b)print(stateCapital.keys())

stateCapital = {"Assam":"Guwahati",
"Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}

Find the output of the following statements:

a) print(stateCapital.get("Bihar"))
b) print(stateCapital.keys())
c) print(stateCapital.values())
d) print(stateCapital.items())
e) print(len(stateCapital))
f) print("Maharashtra" in stateCapital)
g) print(stateCapital.get("Assam"))
h) del stateCapital["Assam"]
print(stateCapital)

Show solution

stateCapital.keys() returns the keys of the dictionary in insertion order.

For the given dictionary, the keys are:

dict_keys(['Assam', 'Bihar', 'Maharashtra', 'Rajasthan'])

Not sure why a step works? check your working in Super Tutor

8(c)print(stateCapital.values())

stateCapital = {"Assam":"Guwahati",
"Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}

Find the output of the following statements:

a) print(stateCapital.get("Bihar"))
b) print(stateCapital.keys())
c) print(stateCapital.values())
d) print(stateCapital.items())
e) print(len(stateCapital))
f) print("Maharashtra" in stateCapital)
g) print(stateCapital.get("Assam"))
h) del stateCapital["Assam"]
print(stateCapital)

Show solution

stateCapital.values() returns the values stored in the dictionary.

So the output is:

dict_values(['Guwahati', 'Patna', 'Mumbai', 'Jaipur'])

Not sure why a step works? check your working in Super Tutor

8(d)print(stateCapital.items())

stateCapital = {"Assam":"Guwahati",
"Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}

Find the output of the following statements:

a) print(stateCapital.get("Bihar"))
b) print(stateCapital.keys())
c) print(stateCapital.values())
d) print(stateCapital.items())
e) print(len(stateCapital))
f) print("Maharashtra" in stateCapital)
g) print(stateCapital.get("Assam"))
h) del stateCapital["Assam"]
print(stateCapital)

Free with a Super Tutor account

8(e)print(len(stateCapital))

stateCapital = {"Assam":"Guwahati",
"Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}

Find the output of the following statements:

a) print(stateCapital.get("Bihar"))
b) print(stateCapital.keys())
c) print(stateCapital.values())
d) print(stateCapital.items())
e) print(len(stateCapital))
f) print("Maharashtra" in stateCapital)
g) print(stateCapital.get("Assam"))
h) del stateCapital["Assam"]
print(stateCapital)

Free with a Super Tutor account

8(f)print("Maharashtra" in stateCapital)

stateCapital = {"Assam":"Guwahati",
"Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}

Find the output of the following statements:

a) print(stateCapital.get("Bihar"))
b) print(stateCapital.keys())
c) print(stateCapital.values())
d) print(stateCapital.items())
e) print(len(stateCapital))
f) print("Maharashtra" in stateCapital)
g) print(stateCapital.get("Assam"))
h) del stateCapital["Assam"]
print(stateCapital)

Free with a Super Tutor account

8(g)print(stateCapital.get("Assam"))

stateCapital = {"Assam":"Guwahati",
"Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}

Find the output of the following statements:

a) print(stateCapital.get("Bihar"))
b) print(stateCapital.keys())
c) print(stateCapital.values())
d) print(stateCapital.items())
e) print(len(stateCapital))
f) print("Maharashtra" in stateCapital)
g) print(stateCapital.get("Assam"))
h) del stateCapital["Assam"]
print(stateCapital)

Free with a Super Tutor account

8(h)del stateCapital["Assam"]
print(stateCapital)

stateCapital = {"Assam":"Guwahati",
"Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}

Find the output of the following statements:

a) print(stateCapital.get("Bihar"))
b) print(stateCapital.keys())
c) print(stateCapital.values())
d) print(stateCapital.items())
e) print(len(stateCapital))
f) print("Maharashtra" in stateCapital)
g) print(stateCapital.get("Assam"))
h) del stateCapital["Assam"]
print(stateCapital)

Free with a Super Tutor account

1Write a program to find the number of times an element occurs in the list.

Free with a Super Tutor account

2Write a program to read a list of n integers (positive as well as negative). Create two new lists, one having all positive numbers and the other having all negative numbers from the given list. Print all three lists.

Free with a Super Tutor account

3Write a program to find the largest and the second largest elements in a given list of elements.

Free with a Super Tutor account

4Write a program to read a list of n integers and find their median.

Note: The median value of a list of values is the middle one when they are arranged in order. If there are two middle values then take their average.

Hint: Use an inbuilt function to sort the list.

Free with a Super Tutor account

5Write a program to read a list of elements. Modify this list so that it does not contain any duplicate elements i.e. all elements occurring multiple times in the list should appear only once.

Free with a Super Tutor account

6Write a program to create a list of elements. Input an element from the user that has to be inserted in the list. Also input the position at which it is to be inserted.

Free with a Super Tutor account

7(a)The program should ask for the position of the element to be deleted from the list and delete the element at the desired position in the list.

Write a program to read elements of a list and do the following.
a) The program should ask for the position of the element to be deleted from the list and delete the element at the desired position in the list.
b) The program should ask for the value of the element to be deleted from the list and delete this value from the list.

Free with a Super Tutor account

7(b)The program should ask for the value of the element to be deleted from the list and delete this value from the list.

Write a program to read elements of a list and do the following.
a) The program should ask for the position of the element to be deleted from the list and delete the element at the desired position in the list.
b) The program should ask for the value of the element to be deleted from the list and delete this value from the list.

Free with a Super Tutor account

8Write a Python program to find the highest 2 values in a dictionary.

Free with a Super Tutor account

9Write a Python program to create a dictionary from a string 'w3resource' such that each individual character mates a key and its index value for first occurrence males the corresponding value in dictionary.

Expected output : {3': 1, 's': 4, 'r': 2, 'u': 6, 'w': 0, 'c': 8, 'e': 3, 'o': 5}

Free with a Super Tutor account

10(a)Display the Name and Phone number for all your friends.

Write a program to input your friend's, names and their phone numbers and store them in the dictionary as the key-value pair. Perform the following operations on the dictionary:
a) Display the Name and Phone number for all your friends.
b) Add a new key-value pair in this dictionary and display the modified dictionary

c) Delete a particular friend from the dictionary
d) Modify the phone number of an existing friend
e) Check if a friend is present in the dictionary or not
f) Display the dictionary in sorted order of names

Free with a Super Tutor account

10(b)Add a new key-value pair in this dictionary and display the modified dictionary

Write a program to input your friend's, names and their phone numbers and store them in the dictionary as the key-value pair. Perform the following operations on the dictionary:
a) Display the Name and Phone number for all your friends.
b) Add a new key-value pair in this dictionary and display the modified dictionary

c) Delete a particular friend from the dictionary
d) Modify the phone number of an existing friend
e) Check if a friend is present in the dictionary or not
f) Display the dictionary in sorted order of names

Free with a Super Tutor account

10(c)Delete a particular friend from the dictionary

Write a program to input your friend's, names and their phone numbers and store them in the dictionary as the key-value pair. Perform the following operations on the dictionary:
a) Display the Name and Phone number for all your friends.
b) Add a new key-value pair in this dictionary and display the modified dictionary

c) Delete a particular friend from the dictionary
d) Modify the phone number of an existing friend
e) Check if a friend is present in the dictionary or not
f) Display the dictionary in sorted order of names

Free with a Super Tutor account

10(d)Modify the phone number of an existing friend

Write a program to input your friend's, names and their phone numbers and store them in the dictionary as the key-value pair. Perform the following operations on the dictionary:
a) Display the Name and Phone number for all your friends.
b) Add a new key-value pair in this dictionary and display the modified dictionary

c) Delete a particular friend from the dictionary
d) Modify the phone number of an existing friend
e) Check if a friend is present in the dictionary or not
f) Display the dictionary in sorted order of names

Free with a Super Tutor account

10(e)Check if a friend is present in the dictionary or not

Write a program to input your friend's, names and their phone numbers and store them in the dictionary as the key-value pair. Perform the following operations on the dictionary:
a) Display the Name and Phone number for all your friends.
b) Add a new key-value pair in this dictionary and display the modified dictionary

c) Delete a particular friend from the dictionary
d) Modify the phone number of an existing friend
e) Check if a friend is present in the dictionary or not
f) Display the dictionary in sorted order of names

Free with a Super Tutor account

10(f)Display the dictionary in sorted order of names

Write a program to input your friend's, names and their phone numbers and store them in the dictionary as the key-value pair. Perform the following operations on the dictionary:
a) Display the Name and Phone number for all your friends.
b) Add a new key-value pair in this dictionary and display the modified dictionary

c) Delete a particular friend from the dictionary
d) Modify the phone number of an existing friend
e) Check if a friend is present in the dictionary or not
f) Display the dictionary in sorted order of names

Free with a Super Tutor account

1Write a program to take in the roll number, name and percentage of marks for n students of Class X and do the following:
- Accept details of the n students (n is the number of students).
- Search details of a particular student on the basis of roll number and display result.
- Display the result of all the students.
- Find the topper amongst them.
- Find the subject toppers amongst them.

(Hint: Use Dictionary, where the key can be roll number and the value an immutable data type containing name and percentage.)

Free with a Super Tutor account

22 more solved questions in Working with Lists and Dictionaries

They are free with a Super Tutor account, along with practice quizzes and flashcards for this chapter. Free to start, no card needed.

Frequently Asked Questions

What are the important topics in Working with Lists and Dictionaries for CBSE Class 11 Informatics Practices?
Key topics in Working with Lists and Dictionaries include Lists: Basics, Indexing, and Properties, List Operations, List Methods and Built-in Functions, Dictionary Basics and Traversal. Study these first, then practise questions on each for Class 11 exams.
Are these NCERT Solutions for Working with Lists and Dictionaries free?
The first 22 of the 44 solutions on this page are open to read. The other 22 are free with a Super Tutor account — signing up is free and needs no card.
How should I revise Working with Lists and Dictionaries for Class 11 exams?
Learn the core ideas first, then work through the 94 practice questions on Working with Lists and Dictionaries. Revise definitions regularly and use flashcards for quick recall before the exam.

Sources & Official References

Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.

For serious students

Get the full Working with Lists and Dictionaries chapter — start free.

Quizzes, flashcards, an AI doubt solver and a study plan for CBSE Class 11 Informatics Practices. Free to start, no card needed.