Tuples and Dictionaries NCERT Solution || Tuples and Dictionaries Class 11 Solution || Tuples and Dictionaries Python Class 11 CS Solution || Tuples and Dictionaries Computer Science Solution || NCERT Tuples and Dictionaries Solution || Tuples and Dictionaries in Python Class 11 CS || Tuples and Dictionaries in Python Solution

Note :-  Please Click on Question to get Answer of that Question !!


Q1. Consider 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 ) )

Q2. Consider the following dictionary stateCapital:

stateCapital = {"AndhraPradesh":"Hyderabad","Bihar":"Patna","Maharashtra":"Mumbai",


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 ["Andhra Pradesh"]

Q3. “Lists and Tuples are ordered”. Explain.

Q4. With the help of an example show how can you return more than one value from a function?

Q5. What advantages do tuples have over lists?

Q6. When to use tuple or dictionary in Python. Give some examples of programming situations mentioning their usefulness.

Q7. Prove with the help of an example that the variable is rebuilt in case of immutable data types.

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

Programming problems

Q1. Write 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.

Q2. Write 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

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

Q4. Write 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}

Q5. Write 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

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post