ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
from itertools import zip_longest, product, combinations, permutations
print(list(zip_longest("ab", [1, 2, 3], fillvalue="-"))[-1], len(list(product("ab", repeat=3))), len(list(combinations(range(5), 2))), len(list(permutations("aab"))))
  1. A. ('-', 3) 8 10 6
  2. B. ('-', 3) 6 10 3
  3. C. (None, 3) 8 10 6
  4. D. ('-', 3) 8 20 6

Correct answer: A. ('-', 3) 8 10 6

zip_longest pads the shorter input with fillvalue. product with repeat=3 gives 2^3 = 8 tuples, C(5,2) = 10, and permutations works on positions, not values, so 'aab' gives 3! = 6 (with duplicates).

More Python Programming questions

Exams that ask this topic