Question 8
Back to Exercise
What is the output of the following Python program?
from itertools import permutations, combinations, product
print(len(list(permutations("abc"))), list(combinations([1, 2, 3], 2)), len(list(product("ab", repeat=3))))
- A 6 [(1, 2), (1, 3), (2, 3)] 8 Correct
- B 3 [(1, 2), (1, 3), (2, 3)] 6
- C 6 [(1, 2), (2, 1), (1, 3)] 8
- D 6 [(1, 2), (1, 3), (2, 3)] 6
Correct Answer: Option A
3! = 6 orderings; combinations ignore order; product with repeat=3 gives 2³ = 8 tuples.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!