Answer to Question #183767 in Python for Shehry

Question #183767

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

 



1
Expert's answer
2021-04-20T15:03:51-0400
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS