Python Itertools Product Function Definition Math