Tuples and Dictionaries

Class 11 · Computer Science · 14 Questions

1intermediate🔧 Apply4 marksShort Answer

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:

2intermediate🔧 Apply4 marksShort Answer

Consider the following dictionary stateCapital: stateCapital = {"AndhraPradesh": "Hyderabad", "Bihar": "Patna", "Maharashtra": "Mumbai", "Rajasthan": "Jaipur"} Find the output of the following statements:

3beginner💡 Understand2 marksShort Answer

"Lists and Tuples are ordered". Explain.

4intermediate🔧 Apply2 marksShort Answer

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

5beginner💡 Understand2 marksShort Answer

What advantages do tuples have over lists?

6intermediate🔍 Analyze5 marksLong Answer

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

7intermediate🔧 Apply3 marksShort Answer

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

8intermediate🔍 Analyze2 marksShort Answer

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

1intermediate🔧 Apply5 marksLong Answer

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. [Hint: You may use the function split()]

2intermediate🔧 Apply5 marksLong Answer

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

3intermediate🔧 Apply4 marksLong Answer

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

4intermediate🔧 Apply4 marksLong Answer

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}

5intermediate🔧 Apply6 marksLong Answer

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:

1advanced✨ Create8 marksCase Study

For the SMIS System given in Chapter 5, let us do the following: Write a program to take in the roll number, name and percentage of marks for n students of Class X. Write user defined functions to - 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 is an immutable data type containing name and percentage]