w3resource
Python Exercises

Python: Compute the product of a list of integers

Python Basic: Exercise-115 with Solution

Write a Python program to compute the product of a list of integers (without using for loop).

Sample Solution:-

Python Code:

from functools import reduce
nums = [10, 20, 30,]
nums_product = reduce( (lambda x, y: x * y), nums)
print("Product of the numbers : ",nums_product)

Sample Output:

Product of the numbers :  6000

Visualize Python code execution:

The following tool visualize what the computer is doing step-by-step as it executes the said program:

Python Code Editor:

 

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to filter the positive numbers from a list.
Next: Write a Python program to print Unicode characters.

What is the difficulty level of this exercise?