Font size
WorksheetsDictionary in Python
Total questions: 10
Worksheet time: 9mins
What is the output of the following code
dict1 = {"key1":1, "key2":2}
dict2 = {"key2":2, "key1":1}
print(dict1 == dict2)
True
False
Select correct ways to create an empty dictionary
sampleDict = {}
sampleDict = dict()
sampleDict = dict{}
Please select all correct ways to empty the following dictionary
student = {
"name": "Emma",
"class": 9,
"marks": 75
}
del student
del student[0:2]
student.clear()
Items are accessed by their position in a dictionary
True
False
Dictionary keys must be immutable
True
False
In Python, Dictionaries are immutable
True
False
________________method removes all items from the particular dictionary.
clear( )
pop( )
del ( )
_________________ method will not only delete the item from dictionary, but also return the deleted value.
del ( )
pop( )
Clear( )
_______________this method deletes the item from the dictionary
pop( )
del( )
clear( )
________________method will returns number of key-value pairs in the given dictionary.
len( )
pop( )
del( )
keys( )
values( )
