/  Python-Dictionary-Quiz

This Quiz contains totally 10 Questions each carry 1 point for you.

1.Which one of the following is correct?
A dictionary can have two same keys with different values.
A dictionary can have two same values with different keys
A dictionary can have two same keys or same values but cannot have two same key-value pair
A python, a dictionary can neither have two same keys nor two same values.

Correct!

Wrong!

2.In Python, Dictionaries are immutable
True
False

Correct!

Wrong!

3.What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}
"john" in d
True
False
None
Error

Correct!

Wrong!

4.To obtain the number of entries in dictionary which command is used?
d.size()
len(d)
size(d)
d.len()

Correct!

Wrong!

5.Select a correct way to empty the following dictionary.
student = {
"name": "Emma",
"class": 9,
"marks": 75
}
del student
del student[0:2]
student.clear()

Correct!

Wrong!

6.Which of the following is not a declaration of the dictionary?
{1: ‘A’, 2: ‘B’}
dict([[1,”A”],[2,”B”]])
{1,”A”,2”B”}
{ }

Correct!

Wrong!

7.If ‘a’ is a dictionary with some key-value pairs, what does a.popitem() do?
Removes an arbitrary element
Removes all the key-value pairs
Removes the key-value pair for the key given as an argument
Invalid method for dictionary

Correct!

Wrong!

8.Which of the following will give error?
dict1={"a":1,"b":2,"c":3}
print(len(dict1))
print(dict1.get("b"))
dict1["a"]=5
None of these.

Correct!

Wrong!

9.Find the output of the following program:
D = {1 : 1, 2 : '2', '1' : 1, '2' : 3}
D['1'] = 2
print(D[D[D[str(D[1])]]])
2
3
'2'
KeyError

Correct!

Wrong!

Share the quiz to show your results !

Subscribe to see your results

Ignore & go to results

Python-Dictionary-Quiz

You got %%score%% of %%total%% right

%%description%%

%%description%%

Where to go ?

Quizzes

Loading...