ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(bool(range(0)), bool(range(1)), bool({0: 0}))
  1. A. False True True
  2. B. True True True
  3. C. False False True
  4. D. False True False

Correct answer: A. False True True

An empty range is falsy, a range with one element is truthy, and a non-empty dict is truthy whatever its values are.

More Python Programming questions

Exams that ask this topic