Credit: Bryce C-R, Julia Lee, Chris Piech, and TY Huang
File: some_sum.py
Write a program that reads in 10 integers from the user and then outputs the sum of the entered values. Here's what the output of the program should look like:
Enter 10 nums. I will show you the sum!
Please enter integer number 1: 1
Please enter integer number 2: 3
Please enter integer number 3: 5
Please enter integer number 4: 7
Please enter integer number 5: 9
Please enter integer number 6: 2
Please enter integer number 7: 4
Please enter integer number 8: 6
Please enter integer number 9: 8
Please enter integer number 10: 10
The sum is: 55
Remember that for a for
loop:
for i in range(15):
# some code...
The counter variable i
will always start at 0 and increase each iteration until it gets to 14, so the for
loop runs a total of 15 times.
Remember that you can print values to the user in a string like this:
"The number is " + str(variable_name) + "!!"
You can also print out values to the user when requesting user input:
x = 5
value = input("Please enter the number + str(x) + ": ")