Which of the following are true of Python dictionaries:
Python Dictionaries

Quiz
•
Computers
•
University
•
Hard
Sangameshwar Biradar
Used 893+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
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.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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) }
3.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
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]
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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]
5.
MULTIPLE SELECT QUESTION
20 sec • 1 pt
Which of the following could be a valid dictionary key:
(3+2j)
('foo', 'bar')
dict(foo=1, bar=2)
'foo'
['foo', 'bar']
6.
MULTIPLE CHOICE QUESTION
20 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
7.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
Suppose you have a dictionary d1. Which of the following effectively creates a variable d2 which contains a copy of d1:
d2 = dict(d1.items())
d2 = dict(d1.keys())
d2 = {}
d2.update(d1)
d2 = dict(d1.values())
d2 = dict(d1)
Create a free account and access millions of resources
Similar Resources on Quizizz
15 questions
Python Dictionaries

Quiz
•
University
15 questions
Python-Day-3

Quiz
•
12th Grade - University
9 questions
OCR A Level Computer Science (H446) - Component 1.3.1 - Compression, Encryption and Hashing

Quiz
•
11th Grade - University
15 questions
Python - from 0 to HERO

Quiz
•
University
12 questions
Python Quiz- 1.9

Quiz
•
University
11 questions
CS1010 Lab 01

Quiz
•
University
6 questions
Python Day 9

Quiz
•
University
8 questions
Listas

Quiz
•
University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade