CBSE Class 11 Computer Science Question 36 of 112

Dictionaries — Question 16

Back to all questions
16
Question

Question 16

What is printed by the following statements ?

D1 = {"cat":12,"dog":6,"elephant":23,"bear":20} 
print(25 in D1)
  1. True
  2. False
  3. Error
  4. None
Answer

False

Reasonin operator is used to check whether a certain key is in the dictionary or not. It is also called containment check. It returns a boolean value.
Here, the expression 25 in D1 will print false, since D1 does not contain 25 key.