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.
The code is formatted for seamless integration into a webpage using the specified HTML structure.
# 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)
Please enter your age (in years): 30
Your age in seconds is: 946728000.0
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