Write a program that asks the user about the number of values he/she wants to enter. Then prompt user to enter the values as per the required number, calculate its sum. The sample output is as follows:
Enter the number of values to be input: 5
Enter the number: 20
Enter the number: 10
Enter the number: 50
Enter the number: 4
Enter the number: 65
The sum is: 149
num = int(input('Enter the number of values to be input: '))
sum = 0
for _ in range(num):
x = int(input('Enter the number: '))
sum += x
print('The sum is: ', sum)
Comments
Leave a comment