If you have any questions, comments or issues with this project please post them here!
How many seconds in a year !!
https://replit.com/@JackAdem/Day-011-Project-11-How-many-seconds-are-in-a-year?v=1
Day 11 of #Replit100DaysOfCode #100DaysOfCode.
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.
Replit- https://replit.com/@Chandler0Bing/100-Days-Of-Code-Day-11
Looks amazing! My only advice, try to find a way to simplify the code.
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.
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.
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