Search Header Logo

Python Dictionaries - Quiz 2

Authored by Talal Saleh

Computers

10th Grade - University

Used 8+ times

Python Dictionaries - Quiz 2
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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():

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?