ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
values = [4, 8, 15, 16, 23, 42]
print(bisect.bisect(values, 15) if False else 0, [v for v in values if v % 2 and v > 10])
  1. A. 0 [15, 23]
  2. B. 0 [15, 23, 42]
  3. C. 2 [15, 23]
  4. D. 0 [4, 8, 15, 16, 23]

Correct answer: A. 0 [15, 23]

The first expression evaluates to 0 because of the if False branch, and bisect is never called, so the missing import does not matter. Only odd values above 10 are kept: 15 and 23.

More Python Programming questions

Exams that ask this topic