given an integer N write program which reads N inputs and prints the product of the given integers
2 3 7
The following set of codes work efficiently:
# product of n integers
N = int(input("Enter a positive integer: "))
integers = []
for i in range(N):
num = int(input("Enter integer {}: ".format(i+1)))
integers.append(num)
# product
product = 1
for integer in integers:
product *= integer
print("Product is", product)
Comments
Leave a comment