ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
import itertools
print(sum(1 for _ in itertools.combinations(range(6), 2)), sum(1 for _ in itertools.permutations(range(4), 2)))
  1. A. 15 12
  2. B. 15 16
  3. C. 12 12
  4. D. 30 12

Correct answer: A. 15 12

Choosing 2 of 6 without order gives C(6, 2) = 15. Ordered pairs of 2 out of 4 give P(4, 2) = 12.

More Python Programming questions

Exams that ask this topic