0% found this document useful (0 votes)
7 views2 pages

Chapter Dictionary Worksheet

This document is a worksheet for Class XI Informatics Practices focusing on dictionaries in Python. It includes multiple-choice questions and programming exercises related to dictionary creation, manipulation, and properties. The worksheet also features assertion and reasoning questions to test understanding of dictionary concepts.

Uploaded by

febisuneer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Chapter Dictionary Worksheet

This document is a worksheet for Class XI Informatics Practices focusing on dictionaries in Python. It includes multiple-choice questions and programming exercises related to dictionary creation, manipulation, and properties. The worksheet also features assertion and reasoning questions to test understanding of dictionary concepts.

Uploaded by

febisuneer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CLASS XI INFORMATICS PRACTICES

CHAPTER : DICTIONARY
WORKSHEET
1. What is the syntax to create an empty dictionary in Python?
a) dict = {} b) dict = [] c) dict = () d) dict = None
2. Which method is used to add a new key-value pair to a dictionary?
a) append() b) update() c) insert() d) add()
3. How do you access the value of a key in a dictionary?
a) dict[key] b) dict.key c) dict.get(key) d) a & c
4. What happens if you try to access a key that doesn't exist in a dictionary?
a) It returns None b) It raises a KeyError
c) It returns an empty string d) It returns 0
5. Which method is used to remove a key-value pair from a dictionary?
a) pop() b) remove() c) delete() d) clear()
6. What is the output of dict.keys()?
a) A list of keys b) A list of values
c) A list of key-value pairs d) A dictionary
7. Which method is used to add new key value pair if not exists ?
a) get() b) setdefault() c) add() d) insert()
8. How do you merge two dictionaries?
a) dict1 + dict2 b) dict1.update(dict2)
c) dict1.merge(dict2) d) dict1.extend(dict2)
9. What is the output of dict.clear()?
a) An empty dictionary
b) A dictionary with one key-value pair
c) A dictionary with all keys removed
d) A dictionary with all values removed
10.What will be the output of the following Python code snippet?
d1={“amit”:40, “jatin”:45}
d2={“amit”:466, “jatin”:45}
d1>d2
a) True b) False c) error d) None
11. Keys must be _____ in dictionary.(Mutable/Immutable)
12. Write output of following statement.
D={“Amit”:40, “Sumit”:35, “Naina”:30}
print(D[“Amit”]+D[“Sumit”])
13. Write output :
d = {"a" : 1 , "b" : 2}
d["c"] = 3
d["b"] = 4
del d["a"]
print(d)
14. Consider the following dictionary stateCapital:
stateCapital = {"Assam":"Guwahati",
"Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}
Find the output of the following statements:
a) print(stateCapital.get("Bihar"))
b) print(stateCapital.keys())
c) print(stateCapital.values())
d) print(stateCapital.items())
e) print(len(stateCapital))
f) print("Maharashtra" in stateCapital)
g) print(stateCapital.get("Assam"))
h) del stateCapital["Assam"]
i) print(stateCapital)
15. Find the incorrect statement/s out of the following:
a) >>> dict1= {'A': 'Apple', 'B':'Boy', 'C':'Cat', 'D':'Dog'}
a) >>>print(len(d)) b) >>>print (dict1[‘a’] )
c) >>> print (dict1[‘B’]) d) >>> print (dict1[‘Cat’] )
e) >>> print(dict1[‘E’] ) f) >>>print(dict1.pop(‘A’))
16. Consider the following dictionary:
states=['D':'Delhi', 'K':'Kerala', 'T':'Tamil Nadu', 'B':'Bihar']
Write Python statements for the following. Kindly state the reason for the operations which is not
possible.
a) To insert (‘R’:“Red Fort”) and (‘J’:“Jantar Mantar”) in the dictionary states
b) To replace the value of key ‘K’ by ‘Karnataka’.
c) To remove the element with key ‘B’.
d) To delete the dictionary, states.
e) To check whether the element with key ‘D’ is present in the dictionary or not.

ASSERTION AND REASONING based questions.


Mark the correct choice as
a. Both A and R are true and R is the correct explanation for A
b. Both A and R are true and R is not the correct explanation for A
c. A is True but R is False
d. A is false but R is True
17. Assertion(A) : Dictionaries are enclosed by curly brackets
Reason(R) : The key value pairs are separated by comms(,)
18. Assertion(A) : Keys of a dictionary must be unique
Reason(R) : The keys of a dictionary can be accessed using values.
19. Assertion(A) : items in dictionaries are unordered.
Reason(R) : You may not get back data in the same order in which you had entered the data initially in the
dictionary.
20. List can be used as keys in a dictionary (True/False).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy