ProgrammingModerateTCS NQT · Accenture
What is printed?
What is printed?
import itertools
print(len(set(itertools.permutations('aab'))), len(list(itertools.permutations('aab'))))- A. 6 3
- B. 3 6
- C. 3 3
- 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
- What is printed? python print(list(zip([iter(range(6))] 2)))
- What is printed? python print(sum(range(106)) % 7)
- What is printed? python print(12 & -12, 12 ^ 12 >> 1)
- What is printed? python print(list(map(lambda a, b: a b, [1, 2, 3], [4, 5])))
- What is printed? python print(max([], default=-1), min(range(0), default='e'))
- What is printed? python from itertools import takewhile, dropwhile a = [1, 3, 5, 2, 7, 1] print(list(takewhile(lambda x: x % 2, a))…