Test 12 questiona 4 5 6 7
Flag question: Question 4
The dictionary dcn is initialized as shown:
dcn = {"x": 10, "y": 20, "z": 30}
Which of the following statements would return True?
"x" in dcn
10 in dcn
Group of answer choices
I only
II only
I and II
Neither I nor II
Flag question: Question 5
What is printed by the following code?
seats = {"Jones": 44, "Nielsson": 46, "Nsona": 50}
changes = {"Jones": 48, "Rodriguez": 52}
seats.update(changes)
print(seats)
Group of answer choices
{'Jones': 48, 'Nielsson': 46, 'Nsona': 50, 'Rodriguez': 52}
{'Jones': 48, 'Nielsson': 46, 'Nsona': 50}
{'Jones': 44, 'Nielsson': 46, 'Nsona': 50, 'Rodriguez': 52}
{'Jones': 44, 'Nielsson': 46, 'Nsona': 50, 'Jones': 48 'Rodriguez': 52}
Flag question: Question 6
Nik wants to update the dictionary dcn so that it adds the key "super" with the value "hero" to his code, but only if there is not already a key "super" in dcn. Which of the following lines of code could they use to achieve this?
Group of answer choices
dcn.setdefault("super", "hero")
dcn.update({"super": "hero"})
dcn["super"] = "hero"
dcn.get("super", "hero")
Flag question: Question 7
What will be printed by the following code?
fruit = {"apples": 8, "oranges": 12, "pears": 4}
number = fruit.get("oranges", 0) + fruit.get("bananas", 0)
print(number)
Group of answer choices
12
0
24
Nothing is printed, there is an error.