Average of two numbers in Python

10/17/2022
All Articles

#Average of two numbers in Python #average of two numbers in python #python average of two numbers #how to average two numbers in python #program #code #python

Average of two numbers in Python

Average of two numbers in Python

This simplest example of python program , as beginner you must  execute this program.

Here we are taking a input as number .the range of number is n .

Enter value which is you want to Sum and we are using loop to sum all number and then  divide total  for finding  average  of given input :

Below is code for average of two or more numbers :

n=int(input("Enter the number of elements to be inserted: "))
arr=[]
for i in range(0,n):
    elem=int(input("Enter element: "))
    arr.append(elem)
avg=sum(arr)/n
print("Average of elements which you are entered ",round(avg,2))

 

Out put : how to average two  or more numbers in python

Enter the number of elements to be inserted: 3
Enter element: 10
Enter element: 20
Enter element: 50
Average of elements : 40 

Article