ProgrammingModerateTCS NQT · Accenture

What is printed?

What is printed?
import itertools
print(len(set(itertools.permutations('aab'))), len(list(itertools.permutations('aab'))))
  1. A. 6 3
  2. B. 3 6
  3. C. 3 3
  4. D. 2 6

Correct answer: B. 3 6

permutations treats the two a's as different positions, so it yields 6 tuples. Removing duplicates with set leaves only 3 distinct arrangements.

More Python Programming questions

Exams that ask this topic