# Day 011 - Project 11 : How many seconds are in a year?

If you have any questions, comments or issues with this project please post them here!

How many seconds in a year !!

Day 11 of #Replit100DaysOfCode #100DaysOfCode.

1 Like

This is mostly a note for myself to keep me going for 100 Days Of Code but where others can also read it if they would like:
Day 11- Just finished day 11 of 100 for #100-days-of-code! I am still enjoying doing this and I canâ€™t wait to get into even more fun stuff down the road. I canâ€™t wait to be on that day 100 where I can look back at where I started and see how much better I have been doing.

2 Likes

Looks amazing! My only advice, try to find a way to simplify the code.

1 Like

Normally I leave the spelling/grammar corrections to @QwertyQwerty88 but this one bothers me. Please change â€śleepâ€ť to â€śleapâ€ť in your code. Thatâ€™s how itâ€™s spelled. Also you might want to change it to â€ś28-30 days in a Monthâ€ť.

I like the double spacing, which makes the output easier to read. The only real problem with your code is that it generates the wrong number. I used a calculator (not Python) to determine this and 60 seconds per minute * 60 minutes per hour * 24 hours per day * 365 days per year = 31536000 seconds per year. I think the problem is using the months (which have variable day numbers) in your calculations. You could do math for each month if you would like. That would be cool to see how many seconds are in each month.

1 Like

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

2 Likes

How many seconds in a year problem, Day11

The code is not outputting an integer and also when answering the input statement even if the answer is either yes or no it always outputs the else statement

Hey @WarOfKratos welcome to the forums!

I see an issue with your code, when printing the statement out you use strings instead of the variable (the quotes make a value a string), you can change it to this instead â†’ `print(OneYear + OneYear2 + OneYear4)` (no quotes means it isnâ€™t a string (unless the variable is a string to start with) you can also put whatever values you want). Instead of using `if input == â€śyesâ€ť` I would recommend using the variable that you declared for the input â†’ `if Leap_Year == â€śyesâ€ť`. Also when typing out your code make sure your lines are on the same indent (it matters with Python), line 8 and 10 are different indents but they should be the same. I hope this helps!

1 Like