Home  >  Article  >  Backend Development  >  Python average value

Python average value

藏色散人
藏色散人Original
2019-10-22 10:50:0129660browse

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

Python average value

Python average value

Python average value

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.

Python average value

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.

Python average value

#The third step is to loop through the numbers to be calculated and calculate the sum value.

Python average value

Finally, calculate the average and output it. Use the "sum/quantity" formula to calculate the average.

Python average value

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.

Python average value

Python average value

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn