Python program to print number of seconds in year with output

# Number of days in a non-leap year
days_in_year = 365

# Number of days in a leap year
days_in_leap_year = 366

# Calculate the number of seconds in a non-leap year
seconds_in_year = days_in_year * 24 * 60 * 60

# Calculate the number of seconds in a leap year
seconds_in_leap_year = days_in_leap_year * 24 * 60 * 60

# Print the results
print("Number of seconds in a non-leap year:", seconds_in_year)
print("Number of seconds in a leap year:", seconds_in_leap_year)
Output : 
Number of seconds in a non-leap year: 31536000
Number of seconds in a leap year: 31622400

Explaination :

To print the number of seconds in a year using Python, you can follow this simple approach. Here, we’ll consider a non-leap year (365 days) and a leap year (366 days).

Non-Leap Year Calculation

A non-leap year has:

  • 365 days
  • Each day has 24 hours
  • Each hour has 60 minutes
  • Each minute has 60 seconds

Thus, the number of seconds in a non-leap year can be calculated as:

seconds_in_year=365×24×60×60

seconds_in_year=365×24×60×60

Leap Year Calculation

A leap year has:

  • 366 days
  • Each day has 24 hours
  • Each hour has 60 minutes
  • Each minute has 60 seconds

Thus, the number of seconds in a leap year can be calculated as:

seconds_in_leap_year=366×24×60×60

seconds_in_leap_year=366×24×60×60

Leave a Reply

Your email address will not be published. Required fields are marked *