Understanding Python Dictionaries

Understanding Python Dictionaries

Assessment

Interactive Video

Computers

9th - 10th Grade

Hard

Created by

Jennifer Brown

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is another name for an associative array in computer science?

List

Map

Queue

Stack

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In Python, what is the structure used to store key/value pairs?

List

Set

Tuple

Dictionary

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is NOT a valid data type for a dictionary key in Python?

Tuple

Integer

String

List

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you add a new key/value pair to an existing dictionary using brackets?

Use the 'append' method

Use the 'insert' method

Use the 'add' method

Assign a value to a key inside brackets

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What error is raised when trying to access a non-existent key in a dictionary?

ValueError

IndexError

TypeError

KeyError

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method can be used to safely retrieve a value from a dictionary with a default if the key is missing?

search

get

find

lookup

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What method can be used to iterate over both keys and values in a dictionary?

keys

values

items

pairs

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?