wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Dictionary in Python

Total questions: 10

Worksheet time: 9mins

Name
Class
Date
1.

What is the output of the following code

dict1 = {"key1":1, "key2":2}

dict2 = {"key2":2, "key1":1}

print(dict1 == dict2)

a)

True

b)

False

2.

Select correct ways to create an empty dictionary

a)

sampleDict = {}

b)

sampleDict = dict()

c)

sampleDict = dict{}

3.

Please select all correct ways to empty the following dictionary

student = {

"name": "Emma",

"class": 9,

"marks": 75

}

a)

del student

b)

del student[0:2]

c)

student.clear()

4.

Items are accessed by their position in a dictionary

a)

True

b)

False

5.

Dictionary keys must be immutable

a)

True

b)

False

6.

In Python, Dictionaries are immutable

a)

True

b)

False

7.

________________method removes all items from the particular dictionary.

a)

clear( )

b)

pop( )

c)

del ( )

8.

_________________ method will not only delete the item from dictionary, but also return the deleted value.

a)

del ( )

b)

pop( )

c)

Clear( )

9.

_______________this method deletes the item from the dictionary

a)

pop( )

b)

del( )

c)

clear( )

10.

________________method will returns number of key-value pairs in the given dictionary.

a)

len( )

b)

pop( )

c)

del( )

d)

keys( )

e)

values( )