CBSE Class 11 Informatics Practices
Question 30 of 40
Practice Paper — Question 5
Back to all questions 5
Question Write the output for the following print statements in Python.
Sub_Teacher = {"English":"Mr. Gill", "Maths": "Mr. R.N. Pandey", "IP":"Ms. Renu Ahuja", "Physics": "Ms. Meenu Lal", "Chemistry":"Ms. Mamta Goel"}
print(Sub_Teacher['Chemistry']) #Line1
print(Sub_Teacher.keys()) #Line2
print(len(Sub_Teacher)) #Line3Ms. Mamta Goel
dict_keys(['English', 'Maths', 'IP', ' Physics', 'Chemistry'])
5
print(Sub_Teacher['Chemistry'])— This line retrieves the value associated with the key 'Chemistry' from the dictionary, which is "Ms. Mamta Goel".print(Sub_Teacher.keys())— This line lists all the keys in theSub_Teacherdictionary. Thekeys()method returns a list of dictionary’s keys.print(len(Sub_Teacher))— This line calculates the number of key-value pairs in theSub_Teacherdictionary using thelen()function. It returns 5, indicating the total number of key-value pairs in the dictionary.