ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
from itertools import product
print(len(list(product('01', repeat=3))), list(product('ab', 'x'))[-1], sum(1 for _ in product(range(3), repeat=2)))
  1. A. 8 ('b', 'x') 9
  2. B. 8 ('a', 'x') 9
  3. C. 6 ('b', 'x') 9
  4. D. 8 ('b', 'x') 6

Correct answer: A. 8 ('b', 'x') 9

Three binary digits give 2^3 = 8 tuples. product of 'ab' and 'x' ends with ('b', 'x'), and two digits from range(3) give 3^2 = 9 tuples.

More Python Programming questions

Exams that ask this topic