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.
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz