Part of the series

Several example codes

~1 min read • Updated Oct 1, 2025

Program Overview

This Python program reads an integer from the user and calculates the average between that number and zero.
The result is displayed with two decimal places.


Python Code:


# Read a number from the user
num = int(input("Enter a number: "))

# Calculate the average between num and 0
average = (num + 0) / 2

# Display the result
print("\n--- Result ---")
print(f"Average between {num} and 0: {average:.2f}")

Sample Output:


Enter a number: 55  

--- Result ---
Average between 55 and 0: 27.50

Step-by-Step Explanation:

- The user enters a number
- The program adds the number to zero and divides by 2
- The result is printed with two decimal places


Written & researched by Dr. Shahin Siami