Report Bug

QusSuppose d = {“john”:40, “peter”:45}, what happens when we try to retrieve a value using the expression d[“susan”]? Qusमान लीजिए कि d = {"जॉन": 40, "पीटर": 45}, तब क्या होता है जब हम एक्सप्रेशन का यूज़ करते हुए value प्राप्त करने का प्रयास करते हैं 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


Solution
C. Since “susan” is not a key in the set, Python raises a KeyError exception



Explanation
Execute in the shell to verify.
Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad