ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print([x for x in range(20) if x % 3 == 0 and x % 4 == 0])
  1. A. [0, 12]
  2. B. [0, 3, 6, 9, 12, 15, 18]
  3. C. [12]
  4. D. [0, 4, 8, 12, 16]

Correct answer: A. [0, 12]

A number divisible by both 3 and 4 is divisible by 12. Within 0 to 19 these are 0 and 12.

More Python Programming questions

Exams that ask this topic