Asked by Rambo
What data structure stores items in key/value pairs?
list
def
dict
str
list
def
dict
str
Answers
Answered by
Rambo
Given a users dict that maps usernames to email addresses, how would you get the email address for the user djs?
email_address = users[0]
email_address = users{"djs"}
email_address = users["djs"]
email_address = users("djs")
email_address = users[0]
email_address = users{"djs"}
email_address = users["djs"]
email_address = users("djs")
Answered by
Rambo
How do you increment the value stored in a variable called score by 1?
score++
score += 1
1 += score
score+
score++
score += 1
1 += score
score+
Answered by
Rambo
How do we get a random key from a menu_items dict using the random module's choice() function?
random_menu_item = choice(menu_items.keys())
random_menu_item = choice(menu_items.items())
random_menu_item = choice(menu_items)
random_menu_item = choice(menu_items.values())
random_menu_item = choice(menu_items.keys())
random_menu_item = choice(menu_items.items())
random_menu_item = choice(menu_items)
random_menu_item = choice(menu_items.values())
Answered by
Rambo
What dict method lets you loop through both the key and the value of the dict in a for loop?
dict.keys()
dict.get()
dict.items()
dict.values()
dict.keys()
dict.get()
dict.items()
dict.values()
Answered by
Rambo
Which of the following methods gets the keys from a dict and lets you use them like a list?
dict.choices()
dict.val()
dict.convert_to_list()
dict.keys()
dict.choices()
dict.val()
dict.convert_to_list()
dict.keys()
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.