Python Online Compiler
Example: Program to Find Average of N Numbers in Python using For loop
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# Program to Find Average of N Numbers in Python using For loop x, y, i, avg = 0, 0, 0, 0 # x - To store the number of elements # avg - To store the total average value # y - To store the total input numbers print ("Enter the number of elements to calculate the average value::") x = int (input ()) print ("\nEnter the ", x, " elements one by one::") for i in range (x): y = int (input ()) avg += y avg /= x print ("\nThe average of the entered input numbers is: ", avg)
5 62 526 6531 55 3265
Output
Clear
ADVERTISEMENTS