Explore BrainMass

An example python script to add numbers

Write a program in python that continually reads in numbers from the user and adds them together until the sum reaches 100. Write another program that reads 100 numbers from the user and prints out the sum.

Solution Preview

Both of these programs will require using a while loop and a couple of variables. In the first problem we will continue to read numbers and sum them up until the sum is greater than 100. In other words, the "while" condition is "sum < 100" and the action we take in ...

Solution Summary

This solution shows how to write a python script to read numbers from the user and add them together. This demonstrates some of the basic python features.