Home CPSC 110

Lab 5: Sum Calculator



To gain experience with looping.



For this lab, you will write a program to calculate the sum of a set of numbers read in by the user.



  1. Start by asking the user how many numbers they will be adding.
  2. Write a loop to loop that many times.
  3. Each time through, ask the user to enter one integer.
  4. Add each integer into a variable which keeps track of the total sum.
  5. At the end, print the sum for the user


Example Run

Below is an example run of how this program should work:

How many numbers to enter? 5
Next number: 7
Next number: 11
Next number: 2
Next number: 19
Next number: 31
Total is 70



When you are finished, please submit the .py file for the lab on Canvas. To do so, you'll need to navigate to where you saved the file on your computer.

Copyright © 2024 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.