Learn about Average of 3 Numbers in Python using Function in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.
Average of 3 Numbers in Python using Function
# Python program to find average of three numbers using function #user-defined function def avg_num(num1, num2, num3): avg = (num1 + num2 + num3)/3 return avg num1 = float(input('first number: ')) num2 = float(input('second number: ')) num3 = float(input('third number: ')) # function call avg = avg_num(num1, num2, num3) # print result print('The average of numbers = ',avg)
first number: 1 second number: 3 third number: 6 The average of numbers = 3.33
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Average of 3 Numbers in Python from User Input