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 your program is finished, email the .py file to ifinlay@umw.edu.

Copyright © 2021 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.