Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 9 (1 point) To access values of a keys in a dictionary, you can use dictionaryname.get(key): dictionaryname.keys(key): O dictionaryname.items(key): dictionaryname.get(value): Question 10 (1 point)

image text in transcribed
image text in transcribed
image text in transcribed
Question 9 (1 point) To access values of a keys in a dictionary, you can use dictionaryname.get(key): dictionaryname.keys(key): O dictionaryname.items(key): dictionaryname.get(value): Question 10 (1 point) In dictionary, the items() method returns a sequence of tuples that contain the keys and values of all items where key is the first element of the tuple and values is the second element True False Question 11 (1 point) Consider the following variable. Which statement gives the value associated with the key a? myvar = [l'a:4:x:2.y:3 2:3 ]] Omyvar['a')[0) Omyvar[1]['a') myvar['a'][1] Omyvar[0]['a') Question 13 (1 point) Saved What is the result of the following statement? contacts = { "Fred": 7235591. "Mary": 3841212, "Bob": 3841212. "Sarah": 2213278) for key in contacts: print(key) It prints values which are phone numbers. Olt prints keys which are phone numbers. Olt prints value which are contact names. It prints keys which are contact names. Question 14 (1 point) Saved What is the result of the following statement? contacts = [ "Fred": 7235591, "Mary': 3841212, "Bob": 3941212, "Sarah": 22132781 "Fred" in contacts False Error None True Question 15 (1 point) What is the result of the following statement? Mycontacts = { "Fred": 7235591, "Mary: 38412121 print(list(Mycontacts, keys())) O'Fred': 'Mary') Ol'Fred', 'Maryl O ("Fred": 7235591, "Mary": 3841212) O ("Fred": 7235591, "Mary': 3841212) Question 16 (1 point) Consider the following variable. Mycontacts = [ "Fred": 7235591. "Mary: 38412121 ho what happens what we try to retrieve value using the expression Mycontacts Tasusan")? Since "susan" is not a key in the set, Python raises a keyError exception. Since "susan" is not a value in the set. Python raises a KeyError exception Since "susan" is not a key in the set. Python raises a syntax error It is executed fine and no exception is raised, and it returns None

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions