English

What will be the output of the following Python code? my_dict = {"name": "Alicia", "age": 27, "city": "DELHI"} print(my_dict.get("profession", "Not Specified")) - Computer Science (Python)

Advertisements
Advertisements

Question

What will be the output of the following Python code?

my_dict = {"name": "Alicia", "age": 27, "city": "DELHI"}
print(my_dict.get("profession", "Not Specified"))

Options

  • Alicia

  • DELHI

  • None

  • Not Specified

MCQ
Advertisements

Solution

Not Specified

Explanation:

The key "profession" does not exist in the dictionary.
The .get() method returns the default value "Not Specified" when the key is missing.

shaalaa.com
  Is there an error in this question or solution?
2025-2026 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×