CBSE Class 11 Informatics Practices Question 25 of 66

Dictionary — Question 8

Back to all questions
8
Question

Question 8

What will be the output of the following Python code snippet?

d1 = { "amit" :40, "jatin" :45}
d2 = { "amit" :466, "jatin" :45}
d1 > d2
  1. True
  2. False
  3. Error
  4. None
Answer

Error

Reason — In Python, we cannot directly compare dictionaries using the > or < operators. Attempting to do so will result in a Error because dictionaries are unordered collections.