Python program to find average of N numbers

Hello everyone, here we will learn a simple logic to find average on N numbers in python. This program takes max numbers from user and calculates the sum of all the numbers in a loop and the final obtained sum is divided by total number of inputs taken. That results as the average of N numbers.

The formula for it is Average = ( n1+n2+n3+.....) / N , where N is the total number of inputs and n1,n2,n3.. are the values of each input.

Program on Github

Average of n number – Code Visualization

Task :

To find average of N numbers with max numbers and its values are given from user.

Approach :

  • Read an input integer for asking max numbers using input() or raw_input().
  • Loop N number of times for taking the value of each number using input() or raw_input(), where N is the value entered in first step.
  • In the loop, sum the value of each number entered.
  • Finally divide the obtained sum with N, where N is the value entered in first step.
  • The result obtained in the previous step is our average we wanted.
  • Print the result.

Program on Github

Program :

Output :

Average on N numbers - programminginpython.com
Average on N numbers – programminginpython.com
Average on N numbers - programminginpython.com
Average on N numbers – programminginpython.com

Program on Github

Similar Programs :

Leave a Reply