Dictionaries — Chapter Test

Answer all 5 questions, then submit. You need 60% to pass. Log in to save progress.

Question 1
How do you access a value in a dictionary?
ABy its index number
BBy its key
CBy its position
DBy slicing
Question 2
Which can NOT be used as a dictionary key?
AA string
BA number
CA tuple
DA list
Question 3
What does d.get("x") return if the key 'x' is not in the dictionary?
AAn error
BNone
C0
DAn empty string
Question 4
Which method is best for looping over both keys and values together?
Akeys()
Bvalues()
Citems()
Dclear()
Question 5
Are dictionaries mutable?
ANo, like tuples
BYes — you can add, change and remove pairs
COnly the keys are mutable
DOnly if you use update()