print(“Seconds in a year”)

seconds_In_Years = int(input("Tell me the year, please: "))

year = 365

hours_a_day = 24

minutes_hour = 60

seconds_minute = 60

seconds_In_Years = year * hours_a_day * minutes_hour * seconds_minute

print(seconds_In_Years)

leap_Year = 366

leap_Year = leap_Year * hours_a_day * minutes_hour * seconds_minute

if seconds_In_Years == 365:

print(“seconds in a leap year”, leap_Year)

else:

print(“There are”, seconds_In_Years, “seconds in a year”)

#
ok so i know i’m missing a part here, bc everything is coming back the same, as if the year is not a leap year. I need to tell the program, what a leap year is, so i just can’t figure out how to incorporate the leap year code into this code…and need some help pls.

Clue: a year is a leap year if it is a multiple of 4. `x % y`

returns the remainder of x÷y.

3 Likes

i got it with some help, and it was my logic in the if statement at the end as i had thought. so, here’s the updated version, which works now thanks again for the help as well

import calendar

year_Input = int(input(“Enter Year”))

isLeapYear = calendar.isleap(year_Input)

year = 365

leap_Year = 366

hours_a_day = 24

minutes_hour = 60

seconds_minute = 60

seconds_In_Years = year * hours_a_day * minutes_hour * seconds_minute

seconds_in_Leap_Years = leap_Year * hours_a_day * minutes_hour * seconds_minute

if isLeapYear:

print("seconds in a leap year are ", seconds_in_Leap_Years)

else:

print("seconds in year ", seconds_In_Years)

also, ps - instead of going that route, i went and did an import of calendar and went that route with the leap year logic

1 Like