
CC103 - Part 2
Authored by ALVIN CERTEZA
Others
University

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
40 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of: d = {'a': 1, 'b': 2} print(d['c'])
None
0
Error
[]
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which method returns a list of key-value tuple pairs?
keys()
values()
items()
get()
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How to safely access a key that may not exist in a dictionary?
dict['key']
dict.get('key')
dict.key
dict.fetch('key')
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of len({'a': 1, 'b': 2, 'a': 3})?
3
2
1
Error
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does dict.update({'c': 3}) do?
Adds key 'c' with value 3
Replaces dictionary
Clears dictionary
Returns error
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will dict.pop('x') do if 'x' does not exist?
Returns None
Raises KeyError
Deletes key
Returns 0
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How to loop over dictionary keys and values? for k, v in ___: ...
dict
dict.items()
dict.keys()
dict.values()
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?