Tuples and Dictionaries — NCERT Solutions
CBSE · Class 11 · Computer Science
NCERT question answers for Tuples and Dictionaries, CBSE Class 11 Computer Science: 13 textbook questions solved step by step. Covers Exercise.
Interactive on Super Tutor
Studying Tuples 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.
The first 7 solutions are open to read. The other 6 are free with a Super Tutor account. Unlock all 13 free in Super Tutor
Exercise
1Consider the following tuples, tuple1 and tuple2:
tuple1 = (23,1,45,67,45,9,55,45)
tuple2 = (100,200)
Find the output of the following statements:
i. print(tuple1.index(45))
ii. print(tuple1.count(45))
iii. print(tuple1 + tuple2)
iv. print(len(tuple2))
v. print(max(tuple1))
vi print(min(tuple1))
vii. print(sum(tuple2))
viii. print(sorted(tuple1))
print(tuple1)Show solution
Using tuple operations:
tuple1.index(45)gives the index of the first45, which is2.tuple1.count(45)counts all45s, which is3.tuple1 + tuple2concatenates the tuples.len(tuple2) = 2max(tuple1) = 67min(tuple1) = 1sum(tuple2) = 100 + 200 = 300sorted(tuple1)returns a list in ascending order.print(tuple1)prints the original tuple unchanged.
So the outputs are:
i. 2
ii. 3
iii. (23, 1, 45, 67, 45, 9, 55, 45, 100, 200)
iv. 2
v. 67
vi. 1
vii. 300
viii. [1, 9, 23, 45, 45, 45, 55, 67]
(23, 1, 45, 67, 45, 9, 55, 45)
Not sure why a step works? check your working in Super Tutor
2Consider the following dictionary stateCapital:
stateCapital = {"AndhraPradesh":"Hyderabad",
"Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}
Find the output of the following statements:
i. print(stateCapital.get("Bihar"))
ii. print(stateCapital.keys())
iii. print(stateCapital.values())
iv. print(stateCapital.items())
v. print(len(stateCapital))
vi print("Maharashtra" in stateCapital)
vii. print(stateCapital.get("Assam"))
viii. del stateCapital["Rajasthan"]
print(stateCapital)Show solution
From the dictionary operations in the chapter:
stateCapital.get("Bihar")returns the value forBihar, which is Patna.keys(),values(), anditems()return the dictionary views in the same order the items were entered.len(stateCapital)is4."Maharashtra" in stateCapitalchecks for the key, so it isTrue.stateCapital.get("Assam")returnsNonebecause the key is not present.- After deleting
"Rajasthan", the remaining dictionary is shown.
So the outputs are:
i. Patna
ii. dict_keys(['AndhraPradesh', 'Bihar', 'Maharashtra', 'Rajasthan'])
iii. dict_values(['Hyderabad', 'Patna', 'Mumbai', 'Jaipur'])
iv. dict_items([('AndhraPradesh', 'Hyderabad'), ('Bihar', 'Patna'), ('Maharashtra', 'Mumbai'), ('Rajasthan', 'Jaipur')])
v. 4
vi. True
vii. None
viii. {'AndhraPradesh': 'Hyderabad', 'Bihar': 'Patna', 'Maharashtra': 'Mumbai'}
Not sure why a step works? check your working in Super Tutor
3"Lists and Tuples are ordered". Explain.Show solution
A list and a tuple are both ordered sequences. This means that every element has a fixed position, so the order in which elements are stored is maintained.
Because they are ordered, we can access elements by index. For example, the first element is at index , the second at index , and so on. In a list or tuple, the same set of elements arranged in a different order is considered different.
So, saying "Lists and Tuples are ordered" means their elements are stored in a definite sequence and can be accessed by position.
Not sure why a step works? check your working in Super Tutor
4With the help of an example show how can you
return more than one value from a function.Show solution
A function can return more than one value by returning a tuple.
Example:
def circle(r):
area = 3.14 * r * r
circumference = 2 * 3.14 * r
return (area, circumference)
radius = 5
area, circumference = circle(radius)
print(area)
print(circumference)Here, the function circle() returns two values: area and circumference. These are packed into a tuple and then unpacked into two variables on the left side of the assignment.
Not sure why a step works? check your working in Super Tutor
5What advantages do tuples have over lists?Show solution
Tuples have these advantages over lists:
- Tuples are immutable: once created, their elements cannot be changed accidentally.
- Because they do not change, iterating through a tuple is faster than through a list.
- Tuples are useful for storing data that should remain fixed, such as records.
So, tuples are better when the data is not meant to change.
Not sure why a step works? check your working in Super Tutor
6When to use tuple or dictionary in Python. Give some
examples of programming situations mentioning
their usefulness.Show solution
Use a tuple when the data is fixed and should not be changed. For example:
- storing a student's roll number, name, and marks together
- storing a record that must remain unchanged
Use a dictionary when data needs to be stored as key-value pairs and accessed by a key. For example:
- storing names of students as keys and their marks as values
- storing state names as keys and capital cities as values
- storing phone numbers of friends with names as keys
So, tuples are useful for fixed ordered data, while dictionaries are useful for mapping one thing to another.
Not sure why a step works? check your working in Super Tutor
7Prove with the help of an example that the variable
is rebuilt in case of immutable data types.Show solution
For an immutable data type, if we try to change a value, Python does not modify the existing object; instead, a new object is created.
Example:
s = "Hello"
print(id(s))
s = s + " World"
print(id(s))The string s is immutable. When " World" is added, the old string is not changed. A new string is created, so the id() value changes. This proves that the variable is rebuilt in case of immutable data types.
Not sure why a step works? check your working in Super Tutor
Give reason. How can it be corrected?
>>> tuple1 = (5) #statement 1
>>> len(tuple1) #statement 2
Free with a Super Tutor account
Free with a Super Tutor account
We can accomplish these by:
(a) writing a user defined function
(b) using the built-in function
Free with a Super Tutor account
Free with a Super Tutor account
Note: Track the count of the letters from the string.
Sample string : 'w3resource'
Expected output : {'3': 1, 's': 1, 'r': 2, 'u': 1, 'w': 1, 'c': 1, 'e': 2, 'o': 1}
Free with a Super Tutor account
a) Display the name and phone number of 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
6 more solved questions in Tuples 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 Tuples and Dictionaries for CBSE Class 11 Computer Science?
Are these NCERT Solutions for Tuples and Dictionaries free?
How should I revise Tuples and Dictionaries for Class 11 exams?
Sources & Official References
- NCERT Official — ncert.nic.in
- CBSE Academic — cbseacademic.nic.in
- CBSE Official — cbse.gov.in
- National Education Policy 2020 — education.gov.in
Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.
More resources for Tuples and Dictionaries
Practice Quiz
Test yourself with a quick quiz
Important Questions
Exam-style questions with answers
Revision Notes
Key points for last-minute revision
Chapter Summary
Understand the chapter at a glance
Concept Maps
See how topics connect
Study Plan
Step-by-step plan for this chapter
Flashcards
Quick-fire cards for active recall
Syllabus
What topics to cover
For serious students
Get the full Tuples and Dictionaries chapter — start free.
Quizzes, flashcards, an AI doubt solver and a study plan for CBSE Class 11 Computer Science. Free to start, no card needed.