Python Practice › Tuple Programs › Program 41
Product of a tuple
Write a Python program to multiply all the elements of a tuple.
Input
(5, 4, 3, 1)
Output
60
Approach
math.prod().
Solution
import mathprint(math.prod((5, 4, 3, 1)))Output
60
Learn the concept
New to this topic? Read the lesson, then come back.