No student devices needed. Know more
8 questions
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) }
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]
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]
A Python dictionary stores ...
value - key pairs
key - value pairs
Which of the following create an empty dictionary (D)?
D = dict()
D = ()
D = []
D = {}
ARE THE KEYS OF A DICTIONARY BE CHANGED
TRUE
FALSE
CAN YOU EDIT A VALUE IN A DICTIONARY?
YES IT IS POSSIBLE
NO IT IS NOT POSSIBLE
Explore all questions with a free account