ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(10 in range(0, 20, 5), 11 in range(0, 20, 5))
  1. A. True True
  2. B. False True
  3. C. True False
  4. D. False False

Correct answer: C. True False

range(0, 20, 5) holds 0, 5, 10 and 15. Membership in a range is checked arithmetically, so 10 is in it and 11 is not.

More Python Programming questions

Exams that ask this topic