This Python program reads three numbers from the user.
It sends them to a method that calculates their average.
The result is returned to the main program and displayed.
This exercise helps practice method definition, parameter passing, and basic arithmetic.
def calculate_average(a, b, c):
return (a + b + c) / 3
# Run the program
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))
average = calculate_average(num1, num2, num3)
print(f"The average is: {average:.2f}")
The average is: 7.00
- The program reads three numbers from the user
- It sends them to a method called calculate_average
- The method adds the numbers and divides the sum by 3
- The result is returned and printed with two decimal places