1.

Suppose d = {“john”:40, “peter”:45}, what happens when we try to retrieve a value using the expression 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» Correct choice is (c) Since “susan” is not a key in the set, Python raises a KeyError exception

Easiest explanation - Execute in the shell to verify.


Discussion

No Comment Found