Skip to main content
Chapter 10 of 11
NCERT Solutions

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.

42 questions68 flashcards5 concepts

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.

13 Questions Solved · 1 Section

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 first 45, which is 2.
  • tuple1.count(45) counts all 45s, which is 3.
  • tuple1 + tuple2 concatenates the tuples.
  • len(tuple2) = 2
  • max(tuple1) = 67
  • min(tuple1) = 1
  • sum(tuple2) = 100 + 200 = 300
  • sorted(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 for Bihar, which is Patna.
  • keys(), values(), and items() return the dictionary views in the same order the items were entered.
  • len(stateCapital) is 4.
  • "Maharashtra" in stateCapital checks for the key, so it is True.
  • stateCapital.get("Assam") returns None because 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 00, the second at index 11, 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

8TypeError occurs while statement 2 is running.
Give reason. How can it be corrected?
>>> tuple1 = (5) #statement 1
>>> len(tuple1) #statement 2

Free with a Super Tutor account

1Write a program to read email IDs of n number of students and store them in a tuple. Create two new tuples, one to store only the usernames from the email IDs and second to store domain names from the email IDs. Print all three tuples at the end of the program. [Hint: You may use the function split()]

Free with a Super Tutor account

2Write a program to input names of n students and store them in a tuple. Also, input a name from the user and find if this student is present in the tuple or not.

We can accomplish these by:

(a) writing a user defined function
(b) using the built-in function

Free with a Super Tutor account

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

Free with a Super Tutor account

4Write a Python program to create a dictionary from a string.
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

5Write a program to input your friends' 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 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?
Key topics in Tuples and Dictionaries include Tuples: Basic Idea and Creation, Tuple Properties and Operations, Tuple Methods and Built-in Functions, Tuple Assignment and Nested Tuples. Study these first, then practise questions on each for Class 11 exams.
Are these NCERT Solutions for Tuples and Dictionaries free?
The first 7 of the 13 solutions on this page are open to read. The other 6 are free with a Super Tutor account — signing up is free and needs no card.
How should I revise Tuples and Dictionaries for Class 11 exams?
Learn the core ideas first, then work through the 42 practice questions on Tuples 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 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.