Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Calculate Average of Three Numbers

Learn to calculate the average of three given numbers using basic arithmetic operations.

Python practice16 minIntermediateLast updated December 26, 2025

Problem statement

You need to write a function that accepts three numeric inputs and computes their average. The average is calculated by summing the numbers and dividing by the count of the numbers. Ensure your function handles floating-point division correctly.

Task

Implement a function that takes three numbers and returns their average.

Examples

Example 1

Input

calculate_average(2, 4, 6)

Output

4.0

The average of 2, 4, and 6 is (2 + 4 + 6) / 3 = 12 / 3 = 4.0.

Input format

Three integers or floats.

Output format

A float representing the average.

Constraints

The inputs can be any numeric type (int or float).

Samples

Sample 1

Input

calculate_average(1, 2, 3)

Output

2.0

The average of 1, 2, and 3 is (1 + 2 + 3) / 3 = 6 / 3 = 2.0.