> Help programming a mean (average) calculator in Python?

Help programming a mean (average) calculator in Python?

Posted at: 2014-12-18 
Ok well to calculate the mean you only need to know two things. The sum of the numbers entered and the amount of numbers entered. So create variables sum and count.

When button is clicked..

- update sum to include number in the textbox

- increment count by 1

- clear the textBox

- calculate new average

- update label to display new average

Hi, I am a Computer Science major currently taking Programming I. I have learned the very basics of Visual Basics, but now we are writing an application in Python. This isn't an actual graded assignment, but rather one the professor only gave to me to do for practice since I'm so far ahead in the class right now. I wrote the basics of the program already, but I'm having some problems. The application needs to contain a single text box for the user to input a single number, a button to calculate mean, and a label to display the mean. The way it is supposed to work is that the user puts a number in (let's say 1), then hits the button and it displays the mean as 1. Now, the user can input another number (let's say 3), and it should add that to the total mean (meaning that the 1 from before is included) and it should give the mean as 2. I have created it with 10 text boxes that all require a number to be input, then it takes the mean of that. My problem is that I couldn't figure out how to do it the way I am supposed to. I get the idea, but I'm unsure of how to write it so that the program remembers the previous numbers and calculates them in with the newly added ones. Any ideas? Sorry I can't paste the code, it doesn't fit in the question space unfortunately. I'm just looking for the equation or how to set this up, I have the basic GUI already.