Part of the series

Several example codes

~1 min read • Updated Sep 16, 2025

Program Overview

This Python program reads a person’s age in years and converts it into seconds.
It uses the average number of seconds in a year, accounting for leap years, to calculate the total.

Python Code:


# One year = 365.25 days (including leap years)
# One day = 86400 seconds

seconds_per_year = 365.25 * 86400

age_years = float(input("Please enter your age (in years): "))
age_seconds = age_years * seconds_per_year

print("Your age in seconds is:", age_seconds)

Sample Output:


Please enter your age (in years): 30
Your age in seconds is: 946728000.0

Explanation:

Here’s how the program works:
- It uses 365.25 days per year to include leap years
- Each day contains 86400 seconds
- The age in years is multiplied by the number of seconds per year
- The result is printed using the print() function


Written & researched by Dr. Shahin Siami