Answer to Question #302424 in Python for khab

Question #302424

Write a Python code that will read 5 numbers from the user. Your program should print the first number, the sum of the first 2 numbers, the sum of the first 3 numbers, and so on up to the sum of 5 numbers.

==========================================================

Sample Input 1:

1

2

3

4

5

Sample Output 1:

1

3

6

10

15


1
Expert's answer
2022-02-27T03:58:21-0500
in_ = [int(input(f'Input number {i+1}: ')) for i in range(5)]
print('='*20)
[print(sum(in_[:i])) for i in range(1,len(in_)+1)]

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