DICTIONARIES
Assessment
•
DHARMENDRA THAKUR
•
Computers
•
11th Grade
•
19 plays
•
Medium
Improve your activity
Higher order questions
Match
•
Reorder
•
Categorization
actions
Add similar questions
Add answer explanations
Translate quiz
Tag questions with standards
More options
8 questions
Show answers
1.
Multiple Choice
Which of the following is not a valid way to define this dictionary in Python:
d = dict([
('foo', 100),
('bar', 200),
('baz', 300)
])
d = {}
d['foo'] = 100
d['bar'] = 200
d['baz'] = 300
d = dict(foo=100, bar=200, baz=300)
d = {'foo': 100, 'bar': 200, 'baz': 300}
d = { ('foo', 100), ('bar', 200), ('baz', 300) }
2.
Multiple Choice
Consider this dictionary:
d = {'foo': 100, 'bar': 200, 'baz': 300}
What is the result of this statement:
d['bar':'baz']
It raises an exception
(200, 300)
200 300
[200, 300]
3.
Multiple Choice
Suppose x is defined as follows:
x = [
'a',
'b',
{
'foo': 1,
'bar':
{
'x' : 10,
'y' : 20,
'z' : 30
},
'baz': 3
},
'c',
'd'
]
What is the expression involving x that accesses the value 30?
x[2]["bar"]["z"]
x[2]["bar"]
x["bar"]["z"]
x[2]["bar"]["z"][3]
4.
Multiple Choice
A Python dictionary stores ...
value - key pairs
key - value pairs
5.
Multiple Select
Which of the following create an empty dictionary (D)?
D = dict()
D = ()
D = []
D = {}
6.
Multiple Choice
{
(
[
:
Explore this activity with a free account
Find a similar activity
Create activity tailored to your needs using
Input Output and Storage Devices
•
1st - 4th Grade
Principles of Programming Languages
•
University
Java Programming
•
2nd Grade
Revision Test
•
4th - 5th Grade
Android
•
2nd - 5th Grade
Input and Output Device
•
1st - 2nd Grade
Algorithms and Flowcharts
•
3rd - 5th Grade
Windows Basics
•
5th Grade