Suppose d = {“john”:40, “peter”:45}, what happens when retieving a value using d[“susan”]?
A. Since “susan” is not a value in the set, Python raises a KeyError exception.
B. It is executed fine and no exception is raised, and it returns None.
C. Since “susan” is not a key in the set, Python raises a KeyError exception.
D. Since “susan” is not a key in the set, Python raises a syntax error.
Answer:A
Suppose d = {“john”:40, “peter”:45}, what happens when retieving a value using d[“susan”]?
A. Since “susan” is not a value in the set, Python raises a KeyError exception. B. It is executed fine and no exception is raised, and it returns None. C. Since “susan” is not a key in the set, Python raises a KeyError exception. D. Since “susan” is not a key in the set, Python raises a syntax error.
Explanation:Execute in the shell to verify.