Skip to content
TestMacher
Chapter 10 · Class 11 Computer Science

Tuples and Dictionaries — Important Questions

59 questions With answers CBSE format

SUMMARY: This chapter introduces tuples and dictionaries in Python, focusing on their properties, usage, and differences from other data structures.
KEY TOPICS: tuples, dictionaries, immutable data types, key-value pairs, accessing elements, iterating over tuples and dictionaries, dictionary methods, tuple operations, nested data structures, applications of tuples and dictionaries

Q1 1 Mark

Tuples in Python are:

AMutable
BImmutable
CHashable
DBoth immutable and hashable
Check answerHide answer
Correct answer: Option 4 — Both immutable and hashable
Q2 1 Mark

A tuple is created using:

ASquare brackets
BCurly braces
CParentheses
DAngle brackets
Check answerHide answer
Correct answer: Option 3 — Parentheses
Q3 1 Mark

Which method returns all the keys of a dictionary?

Akeys()
Bget_keys()
Callkeys()
DKeys()
Check answerHide answer
Correct answer: Option 1 — keys()
Q4 1 Mark

Dictionaries in Python store data as:

AIndexed elements
BKey-value pairs
CSets of values
DTuples
Check answerHide answer
Correct answer: Option 2 — Key-value pairs
Q5 1 Mark

The output of {1:'a' 2:'b'}[2] is:

Aa
Bb
C1
D2
Check answerHide answer
Correct answer: Option 2 — b
Q6 1 Mark

What is the primary characteristic of a tuple in Python?

AIt is mutable
BIt is immutable
CIt can store only integers
DIt can only store strings
Check answerHide answer
Correct answer: Option 2 — It is immutable
Q7 1 Mark

Which of the following methods can be used to remove a key-value pair from a dictionary?

Aremove()
Bdelete()
Cpop()
Ddiscard()
Check answerHide answer
Correct answer: Option 3 — pop()
Q8 1 Mark

How can you access the first element of a tuple named 'my_tuple'?

Amy_tuple[0]
Bmy_tuple(1)
Cmy_tuple.first()
Dmy_tuple{0}
Check answerHide answer
Correct answer: Option 1 — my_tuple[0]
Q9 1 Mark

Which of the following is true about dictionaries in Python?

AThey can have duplicate keys
BThey are ordered collections
CKeys must be immutable
DValues must be unique
Check answerHide answer
Correct answer: Option 3 — Keys must be immutable
Q10 1 Mark

What will be the output of the expression len((1, 2, 3, 4))?

A3
B4
C5
DError
Check answerHide answer
Correct answer: Option 2 — 4
Q11 1 Mark

Which of the following statements correctly creates a dictionary?

Amy_dict = {1, 2, 3}
Bmy_dict = (1: 'a', 2: 'b')
Cmy_dict = {1: 'a', 2: 'b'}
Dmy_dict = [1: 'a', 2: 'b']
Check answerHide answer
Correct answer: Option 3 — my_dict = {1: 'a', 2: 'b'}
Q12 1 Mark

What is the result of the expression (1, 2) + (3, 4)?

A(1, 2, 3, 4)
B(1, 2)(3, 4)
C(1, 2, (3, 4))
DError
Check answerHide answer
Correct answer: Option 1 — (1, 2, 3, 4)
Q13 1 Mark

Which method would you use to get a list of all values in a dictionary?

Avalues()
Bget_values()
Call_values()
Dlist_values()
Check answerHide answer
Correct answer: Option 1 — values()
Q14 1 Mark

What happens if you try to change an element of a tuple?

AThe element changes
BA new tuple is created
CAn error is raised
DThe program crashes
Check answerHide answer
Correct answer: Option 3 — An error is raised
Q15 1 Mark

In a dictionary, what is the purpose of a key?

ATo store values
BTo identify values uniquely
CTo sort the dictionary
DTo create nested dictionaries
Check answerHide answer
Correct answer: Option 2 — To identify values uniquely
Q16 3 Marks

Differentiate between list and tuple in Python.

Q17 3 Marks

Differentiate between tuple and dictionary in Python.

Q18 3 Marks

Write Python code to count the frequency of each word in a sentence using a dictionary.

Q19 3 Marks

Explain how to create an empty tuple and an empty dictionary.

Q20 3 Marks

How do you check if a key exists in a dictionary?

Q21 3 Marks

What are the main characteristics of tuples in Python?

View sample solutionHide solution
Tuples are immutable data types, meaning once they are created, their elements cannot be changed. They can contain mixed data types and are defined using parentheses, e.g., (1, 'apple', 3.14).
Q22 3 Marks

How can you access elements in a tuple?

View sample solutionHide solution
Elements in a tuple can be accessed using indexing, similar to lists. For example, if 't' is a tuple, 't[0]' will return the first element of the tuple.
Q23 3 Marks

What is the purpose of the 'get' method in dictionaries?

View sample solutionHide solution
The 'get' method in dictionaries is used to retrieve the value associated with a specified key. It returns 'None' if the key does not exist, allowing for safer access without raising an error.
Q24 3 Marks

Explain how to iterate over a dictionary and print its key-value pairs.

View sample solutionHide solution
You can iterate over a dictionary using a for loop. For example, for 'key, value in my_dict.items():', you can print 'key' and 'value' to display each key-value pair in the dictionary.
Q25 3 Marks

What happens if you try to change an element of a tuple?

View sample solutionHide solution
If you attempt to change an element of a tuple, Python will raise a TypeError, indicating that tuples do not support item assignment due to their immutable nature.
Q26 6 Marks

Compare tuple and dictionary with the help of a table on five features.

Q27 6 Marks

Differentiate between list tuple and dictionary in tabular form on five points.

Q28 6 Marks

Compare keys() and values() dictionary methods with the help of a table.

Q29 6 Marks

Write a Python program to convert two parallel lists into a dictionary.

Q30 6 Marks

Discuss any five built-in dictionary methods with one example each.

Q31 6 Marks

Write a Python program using a dictionary to store student names as keys and their marks as values then find the topper.

Q32 1 Mark

Assertion (A): Tuples are immutable.

Reason (R): They cannot be modified after creation.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q33 1 Mark

Assertion (A): Dictionaries are unordered collections.

Reason (R): Items are accessed by key not position.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q34 1 Mark

Assertion (A): Dictionary keys must be unique.

Reason (R): Duplicate keys would create ambiguity.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q35 1 Mark

Assertion (A): Dictionary keys must be immutable.

Reason (R): Lists cannot be used as dictionary keys.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q36 1 Mark

Assertion (A): Tuples can be used as dictionary keys.

Reason (R): They are immutable and hashable.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q37 1 Mark

Assertion (A): Tuples can contain elements of different data types.

Reason (R): Dictionaries can only store values of the same data type.

Show explanationHide explanation
Correct answer: Option 3 — A is true, but R is false.
Q38 1 Mark

Assertion (A): You can access elements of a tuple using indexing.

Reason (R): Dictionaries use indexing to access their values.

Show explanationHide explanation
Correct answer: Option 3 — A is true, but R is false.
Q39 1 Mark

Assertion (A): Dictionaries allow duplicate keys.

Reason (R): Dictionaries store data in key-value pairs.

Show explanationHide explanation
Correct answer: Option 4 — A is false, but R is true.
Q40 1 Mark

Statement 1: Tuples are faster than lists for iteration.

Statement 2: They have lower memory overhead.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q41 1 Mark

Statement 1: Dictionary values can be of any data type.

Statement 2: Keys must be of immutable types like int float string or tuple.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q42 1 Mark

Statement 1: Tuples are written using parentheses.

Statement 2: A single-element tuple needs a trailing comma.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q43 1 Mark

Statement 1: The get() method retrieves a value for a given key.

Statement 2: It returns None if the key is absent.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q44 1 Mark

Statement 1: The items() method returns key-value pairs as a list of tuples.

Statement 2: It is useful for iterating over dictionary entries.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q45 1 Mark

Statement 1: Tuples can be modified after their creation.

Statement 2: Dictionaries are mutable data types.

Show answerHide answer
Correct answer: Option 2 — Only Statement 1 is true.
Q46 1 Mark

Statement 1: A tuple can contain elements of different data types.

Statement 2: Dictionaries can only have string keys.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q47 1 Mark

Statement 1: The length of a tuple can be changed after it is created.

Statement 2: Dictionaries allow for duplicate keys.

Show answerHide answer
Correct answer: Option 4 — Both statements are false.
Q48 3 Marks
A student wants to build a simple phone book using a Python dictionary where contact names are keys and phone numbers are values. She needs to add new contacts search a contact by name update a number and delete a contact.
  1. Which Python data type stores key-value pairs?
    AList
    BTuple
    CDictionary
    DSet
  2. Tuples in Python are:
    AMutable
    BImmutable
    CHashable
    DBoth immutable and hashable
  3. Write a Python program to implement a phone book with add search update and delete operations.
Show answersHide answers
1. Option 3 — Dictionary
2. Option 4 — Both immutable and hashable
3. phonebook = {} # empty dict. # Add: phonebook['Anil'] = '9876543210'. # Search: print(phonebook.get('Anil' 'Not found')). # Update: phonebook['Anil'] = '9876543211'. # Delete: del phonebook['Anil']. The get() method is preferred over [] for searching because it returns a default if the key is absent. Dictionary keys must be unique and immutable.
Q49 4 Marks
In Python, tuples are immutable sequences that can hold a variety of data types. Unlike lists, once a tuple is created, its elements cannot be modified, added, or removed. This property makes tuples suitable for storing fixed collections of items. For example, a tuple can be used to store the coordinates of a point in a 2D space, such as (3, 5). On the other hand, dictionaries are mutable data structures that store data in key-value pairs. Each key in a dictionary must be unique, and it allows for fast retrieval of values based on those keys. For instance, a dictionary can be used to map student IDs to their names, enabling quick access to a student's information using their ID as the key.
  1. What is the main characteristic of tuples in Python?
    AThey are mutable.
    BThey are immutable.
    CThey can only hold integers.
    DThey can only hold strings.
  2. Explain why dictionaries are preferred for fast data retrieval.
  3. Which of the following is true about the keys in a dictionary?
    AKeys can be duplicated.
    BKeys must be unique.
    CKeys can be mutable.
    DKeys can only be strings.
  4. Provide an example of a scenario where a tuple would be more appropriate than a list.
Show answersHide answers
1. Option 2 — They are immutable.
2. Dictionaries use unique keys for each value, allowing for O(1) average time complexity for lookups.
3. Option 2 — Keys must be unique.
4. Storing the geographical coordinates of a location, such as (latitude, longitude).
Q50 4 Marks
Tuples and dictionaries are essential data structures in Python that serve different purposes. Tuples are often used to group related data together. For instance, a tuple can represent a record, such as a book with attributes like title, author, and year published. Since tuples are immutable, they ensure that the data remains constant throughout the program. In contrast, dictionaries are highly flexible and allow for dynamic data manipulation. They are particularly useful when you need to associate a unique identifier with a value, such as a product ID with its price. The ability to add, update, or delete entries in a dictionary makes it an invaluable tool for managing collections of data.
  1. What type of data structure is best suited for storing a fixed collection of items?
    AList
    BTuple
    CDictionary
    DSet
  2. Describe a situation where using a dictionary would be advantageous.
  3. Which of the following statements about tuples is correct?
    ATuples can be modified after creation.
    BTuples can contain mixed data types.
    CTuples cannot be nested.
    DTuples are slower than lists.
  4. What is a common application of dictionaries in programming?
Show answersHide answers
1. Option 2 — Tuple
2. When you need to map unique identifiers to values, such as student IDs to student names.
3. Option 2 — Tuples can contain mixed data types.
4. Storing user preferences where each preference is associated with a unique key.
Q51 4 Marks
In Python, tuples can be created using parentheses, while dictionaries are defined using curly braces. A tuple is defined by placing comma-separated values within parentheses, such as (1, 2, 3). In contrast, a dictionary consists of key-value pairs, separated by colons, like {'name': 'Alice', 'age': 25}. One of the key advantages of using tuples is their ability to serve as keys in dictionaries, as they are hashable. This means that you can use a tuple as a key to access a value in a dictionary, which is not possible with lists. This feature allows for complex data structures, such as dictionaries of tuples, to be easily implemented.
  1. How are tuples created in Python?
    AUsing square brackets.
    BUsing parentheses.
    CUsing curly braces.
    DUsing angle brackets.
  2. Explain why tuples can be used as keys in dictionaries.
  3. Which of the following is the correct syntax for a dictionary?
    A{'key': 'value'}
    B[key: value]
    C(key, value)
    D<key, value>
  4. Provide an example of a tuple that could be used as a key in a dictionary.
Show answersHide answers
1. Option 2 — Using parentheses.
2. Tuples are hashable and immutable, making them suitable for use as dictionary keys.
3. Option 1 — {'key': 'value'}
4. (1, 'apple')
Q52 6 Marks

For dict d = {'a':1, 'b':2, 'c':3}, predict each operation's result.

Operation on d = {'a':1,'b':2,'c':3}Result
d['a']?
d['d'] = 4 (then d)?
d.keys()?
d.values()?
d.get('e', 0)?
Q53 5 Marks

Predict the output of each tuple operation.

Operation on t = (1, 2, 3, 4)Result
len(t)?
t[0]?
t[-1]?
t[0:2]?
t + (5, 6)?
t * 2?
Q54 3 Marks

Study the table comparing list tuple and dictionary and answer:

FeatureListTupleDictionary
Mutable?YesNoYes
Ordered?YesYesYes (3.7+)
Indexed byPositionPositionKey
Syntax[](){}
DuplicatesAllowedAllowedKeys unique
  1. Which is immutable in Python?
    AList
    BTuple
    CDictionary
    DAll three
  2. Which uses curly braces { } for syntax?
    AList
    BTuple
    CDictionary
    DSet
  3. Compare list tuple and dictionary on five features with one example each.
Show answersHide answers
1. Option 2 — Tuple
2. Option 3 — Dictionary
3. Lists are mutable ordered sequences indexed by position; use [] syntax. Tuples are immutable ordered sequences also indexed by position; use (). Dictionaries are mutable mappings of keys to values indexed by key; use {}. Tuples are faster than lists and can serve as dictionary keys (because they are immutable and hashable). Dictionaries provide O(1) lookup by key.
Q55 6 Marks

What is the maximum value in the tuple provided in the table?

Tuple Elements
1
5
3
7
2
Q56 3 Marks

Study the dictionary key-value lookup and answer:

Tuples and Dictionaries figure
  1. To safely retrieve a value from a dictionary use:
    Ad['marks']
    Bd.get('marks')
    CBoth work
    DNeither works
  2. Which method returns key-value pairs as tuples?
    Akeys()
    Bvalues()
    Citems()
    Dall()
  3. Discuss the structure of a dictionary in Python with examples of common methods.
Show answersHide answers
1. Option 3 — Both work
2. Option 3 — items()
3. A dictionary stores key-value pairs. Keys must be unique and immutable; values can be any type. Lookup by key is O(1) on average. The get() method is preferred over [] because it returns a default if the key is absent (no KeyError). keys() values() and items() return views over the dictionary.
Q57 2 Marks

Based on the given diagram of a tuple structure in Python, answer the following:

Tuples and Dictionaries figure
  1. What is the type of the first element in the tuple?
    AInteger
    BString
    CFloat
    DList
  2. Explain why tuples are considered immutable.
Show answersHide answers
1. Option 1 — Integer
2. Tuples cannot be modified after their creation.
Q58 2 Marks

Based on the given flowchart, answer the following:

Tuples and Dictionaries figure
  1. Which method is used to retrieve a value associated with a key?
    Aadd()
    Bremove()
    Cget()
    Dupdate()
  2. What is the purpose of the 'remove()' method?
Show answersHide answers
1. Option 3 — get()
2. To delete a key-value pair from the dictionary.
Q59 2 Marks

Based on the given chart, answer the following:

Tuples and Dictionaries figure
  1. Which operation has a time complexity of O(1)?
    AAccess
    BCount
    CAppend
    DIndex
  2. What can be inferred about the 'Append' operation for tuples?
Show answersHide answers
1. Option 1 — Access
2. Tuples do not support appending as they are immutable.

Make a full Computer Science paper on Tuples and Dictionaries.

Pick the question mix, set the marks, hit generate. You get a ready-to-print paper with an answer key.

Generate your paper — free