ProgrammingModerateTCS NQT · Accenture

What is printed?

What is printed?
print(len(set(map(lambda x: x % 3, range(10)))), sum(1 for _ in filter(None, [0, 1, '', 'a', None])))
  1. A. 2 2
  2. B. 3 3
  3. C. 3 2
  4. D. 2 3

Correct answer: C. 3 2

The residues of 0 to 9 modulo 3 are only 0, 1 and 2. filter(None, ...) keeps only truthy items, so 0, '' and None are dropped.

More Python Programming questions

Exams that ask this topic