Question 1
What is printed by the following program?
d = {'Imran': 14, 'Dev': 74, 'Zoya': 45, 'Kiran': 30}print(d["Nobody"])4KeyErrorNone14
Week 7 of Programming in Python: Collections: dicts, sets. Extra important questions based on the recent, changing patterns of the exams, from basic to advanced. Practise them in learning mode: each question has a worked solution.
What is printed by the following program?
d = {'Imran': 14, 'Dev': 74, 'Zoya': 45, 'Kiran': 30}print(d["Nobody"])4
KeyError
None
14
What will be the output of the code below?
d = {'Zoya': 29, 'Nila': 42, 'Kiran': 61, 'Meena': 93}d["Zoya"] = d["Zoya"] + 5d["Zed"] = 1print(d["Zoya"], len(d))34 4
KeyError
34 5
35 5
Consider the program given below. What does it print?
d = {'Imran': 67, 'Ravi': 88, 'Nila': 73, 'Asha': 26}d["Imran"] = d["Imran"] + 5d["Zed"] = 1print(d["Imran"], len(d))72 4
72 5
73 5
KeyError
Authorise with Google to see every question with its answer and explanation and practise it in learning mode.