Program to Find Average of N Numbers in Python using For loop
ADVERTISEMENTS
Program to find average of N numbers in python using for loop. In this article, you will learn how to make a program to find average of N numbers in python using for loop.
Source Code
# 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)
Output
Enter the number of elements to calculate the average value::
5
Enter the 5 elements one by one::
62
526
6531
55
3265
The average of the entered input numbers is: 2087.8