Python Dictionaries - Quiz 2

Python Dictionaries - Quiz 2

Assessment

Quiz

Computers

10th Grade - University

Hard

Created by

Talal Saleh

Used 8+ times

FREE Resource

Student preview

quiz-placeholder

13 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Which of these about a dictionary is false?

The values of a dictionary can be accessed using keys

The keys of a dictionary can be accessed using values

Dictionaries aren’t ordered

Dictionaries are mutable

2.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Which of the following is not a declaration of the dictionary?

d = {1: ‘A’, 2: ‘B’}

d = dict([[1,”A”],[2,”B”]])

d = {1,”A”,2”B”}

d = { }

3.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What will be the output of the following Python code snippet?

a={1:"A",2:"B",3:"C"}

for i,j in a.items():

print(i,j,end=" ")

1 A 2 B 3 C

1 2 3

A B C

1:”A” 2:”B” 3:”C”

4.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What will be the output of the following Python code?
a={1:"A",2:"B",3:"C"}
b={4:"D",5:"E"}
a.update(b)
print(a)

{1: ‘A’, 2: ‘B’, 3: ‘C’}

Method update() doesn’t exist for dictionaries

{1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’, 5: ‘E’}

{4: ‘D’, 5: ‘E’}


5.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What will be the output of the following Python code?

 a={1:"A",2:"B",3:"C"}

b=a.copy()
b[2]="D"
print(a)

Error, copy() method doesn’t exist for dictionaries

{1: ‘A’, 2: ‘B’, 3: ‘C’}

{1: ‘A’, 2: ‘D’, 3: ‘C’}

“None” is printed

6.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What will be the output of the following Python code?

 a={1:"A",2:"B",3:"C"}

a.clear()
print(a)

None

{ None:None, None:None, None:None}

{1:None, 2:None, 3:None}

{ }

7.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What will be the output of the following Python code?

a={1:"A",2:"B",3:"C"}

for i in a:

print(i,end=" ")

1 2 3

‘A’ ‘B’ ‘C’

1 ‘A’ 2 ‘B’ 3 ‘C’

Error, it should be: for i in a.items():

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?