Search Header Logo

Python Dictionaries

Authored by Mrs.C. Rathika

Computers

Used 1+ times

Python Dictionaries
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

20 questions

Show all answers

1.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

1. Which of the following will result in an error for a given valid dictionary D?

D+3  

D*3  

D.update({3:"3"})

D.update("3":3)

2.

MULTIPLE SELECT QUESTION

30 sec • 1 pt

Which of the following are true of Python dictionaries:

Dictionaries can be nested to any depth.

Dictionaries are accessed by key.

All the keys in a dictionary must be of the same type.

Dictionaries are mutable.

A dictionary can contain any object type except another dictionary.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You have the following dictionary definition:


d = {'foo': 100, 'bar': 200, 'baz': 300}


What method call will delete the entry whose value is 200?

delete d('bar')

d.pop("bar")

d.remove("bar")

None of the above

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What would be the output of the following code snippet?


a_dict = {'color': 'blue', 'fruit': 'apple', 'pet': 'dog'}


for key in a_dict:

print(key)

'blue'

'apple'

'dog'

color

fruit

pet

blue

apple

dog

'color'

'fruit'

'pet'

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What would be the output of the following code snippet?


a_dict = {'color': 'blue', 'fruit': 'apple', 'pet': 'dog'}

d_items = a_dict.items()

print(d_items)

('color', 'blue'), ('fruit', 'apple'), ('pet', 'dog')

dict_items([('color'), ('fruit'), ('pet')])

[('color', 'blue'), ('fruit', 'apple'), ('pet', 'dog')]

dict_items([('color', 'blue'), ('fruit', 'apple'), ('pet', 'dog')])

6.

MULTIPLE SELECT QUESTION

30 sec • 1 pt

Which of the following create an empty dictionary (D)?

D = dict()

D = ()

D = []

D = {}

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which symbol surrounds a dictionary?

{
(
[
:

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?