Product of the Given Numbers
Given an integer N, write a program which reads N inputs and prints the product of the given input integers.
Input
The first line of input is a positive integer, N. The next N lines each contain an integer.
Output
The output should be the product of the given input integers.
In the given example,
N = 3 and the input integers are 2, 3, and 7.So, the output should be 2 x 3 x 7 = 42.
Sample Input 1
3
2
3
7
Sample Output 1
42
Sample Input 2
4
11
2
4
9
Sample Output 2
792
n = int(input())
ans = 1
for i in range(n):
k = int(input())
ans *= k
print(ans)
Sample Input 1
3
2
3
7
Sample Output 1
42
Sample Input 2
4
11
2
4
9
Sample Output 2
792
Comments
Leave a comment