Created
March 11, 2021 16:29
-
-
Save gitaficionado/ae1491cc3d6c51c297eed696f1d0251d to your computer and use it in GitHub Desktop.
Ask the user how many numbers for which they want to calculate the sum. Using a for loop, prompt the user to enter that many numbers, one-by-one, keeping track of the sum. At the end, after the user entered all numbers, output the sum.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
3. Ask the user how many numbers for which they want to calculate the sum. Using a for loop, prompt the user to enter that many numbers, one-by-one, keeping track of the sum. At the end, after the user entered all numbers, output the sum. | |
Create a variable and assign it the value of 0 | |
Prompt the user for how many numbers they have | |
With a for loop, set it to repeat enough times to get all their values | |
Prompt the user for a number | |
Add that number to the variable that started as 0 | |
Output to the user, the sum of all values | |
''' | |
# Loop Problem 3 | |
answer = ___ | |
total = ____ | |
answer = int(input("How many numbers do you have? ")) | |
for i in range(______): | |
num = int(input("Please enter a number: ")) | |
total = total + ____ | |
print("The sum of all of your values is: " + str(______)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment