Informatics Practices

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

Python Dictionaries

3 Likes

Answer

Both 2 and 3

Reason — Student.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.

Answered By

2 Likes


Related Questions