3 ms·
The product of two iterables is a list of pairs of each item in the first iterable and each item in the second iterable (same as set product in math): [a, b] ×
by Asooka 7y ago
The product of two iterables is a list of pairs of each item in the first iterable and each item in the second iterable (same as set product in math):
[a, b] × [c, d] = [(a, b), (a, c), (b, c), (b, d)]
The number of elements of the product of two iterables is the product of the number of elements of each. You can similarly have a product of 3, 4, etc. iterables.
The repeat keyword argument to product specifies that we want not a product of several different iterables, but the product of an iterable with itself N times. So we pass a tuple of all possible boolean values (True, False) and ask that it be raised to the 6th power, giving us all possible 6-tuples of all possible boolean values.