Home > Article > Backend Development > Python average value
python average calculation
First of all, let’s take a look at the IPO model for calculating the average.
Input: The number to be entered to calculate the average.
Processing: average algorithm
Output: average
Recommended: "python tutorial"
Understand the IPO of the program After mode, we open the local python IDE tool and create a new python file named test6.py.
Recommended Manual:Python 3 Tutorial
Open test6.py and perform encoding. In the first step, the user is prompted to enter the required Calculate the average of a number of numbers.
The second step is to initialize the value of sum. Note that it is a good coding practice to give an initial value when defining a variable.
#The third step is to loop through the numbers to be calculated and calculate the sum value.
Finally, calculate the average and output it. Use the "sum/quantity" formula to calculate the average.
After the encoding is completed, remember to save and then debug and run. Press the F5 key or click "run"->"run model" in the menu bar to run the program.
Recommended related articles:
1.How to find the average using python
2.Evenly split list in python
Related video recommendations:
1.Little Turtle’s zero-based entry learning Python video tutorial
The above is the detailed content of Python average value. For more information, please follow other related articles on the PHP Chinese website!