ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(any(x > 3 for x in range(10)), next(x for x in range(10) if x * x > 20), sum(x for x in range(0, 10, 4)))
  1. A. True 5 15
  2. B. False 5 12
  3. C. True 5 12
  4. D. True 4 12

Correct answer: C. True 5 12

any stops at the first x greater than 3, so it is True. The first x with x*x > 20 is 5, since 4*4 = 16 and 5*5 = 25. range(0, 10, 4) gives 0, 4 and 8, which sum to 12.

More Python Programming questions

Exams that ask this topic