ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(3 in {1: 'a', 3: 'b'}, '3' in {1: 'a', 3: 'b'}, 3 in [1, 3], 3 in range(3, 4))
  1. A. True False False True
  2. B. True False True True
  3. C. False False True True
  4. D. True True True True

Correct answer: B. True False True True

Membership in a dict checks keys, and 3 is a key but '3' is not. Lists check values, and range checks whether the number falls in its arithmetic sequence.

More Python Programming questions

Exams that ask this topic