Skip to content
Home » Find the Average of 5 Numbers using Function in Python

Find the Average of 5 Numbers using Function in Python

Learn about Find the Average of 5 Numbers using Function in Python in the below code example. Also, refer the comments in the code snippet to get a detailed view about what’s actually happening.

Find the Average of 5 Numbers using Function in Python

# Program to find average of five numbers using function

#function
def avg_num(num1, num2, num3, num4, num5):  
    avg = (num1 + num2 + num3+ num4 + num5) / 5  
    return avg 

num1 = float(input('first number: '))
num2 = float(input('second number: '))
num3 = float(input('third number: '))
num4 = float(input('four number: '))
num5 = float(input('fifth number: '))

# function call
average = avg_num(num1, num2, num3, num4, num5)

# print result
print('The average of numbers = ',average)

Output:

first number: 2
second number: 4
third number: 6
four number: 8
fifth number: 10
The average of numbers =  6.0

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Code : Python Program to Calculate the Average of 5 Numbers