CBSE Class 11 Informatics Practices Question 27 of 66

Dictionary — Question 10

Back to all questions
10
Question

Question 10

Select the correct option to get the values of marks key:

Student={ "name" : "Emma", "class" :11, "sec": "a", "marks" :76}
  1. Student.get(3)
  2. Student.get("marks")
  3. Student["marks"]
  4. Both 2 and 3
Answer

Both 2 and 3

ReasonStudent.get("marks") and Student["marks"] both access the value associated with the key "marks" in the Student dictionary. While Student.get(3) would return "None" because there is no key 3 in the dictionary.