Day 1: How many days, minutes and seconds does the year have?

For New Years we are writing a Python program that calculates days, hours and seconds of a given year. It also checks if the year is a leap year and adds a day.

The result looks like this

 

The code is pretty straight forward and looks like this:

def day_hours(year, is_leap_year):
    if (is_leap_year):
        days = 366
    else:
        days = 365
    print ("The year " + str(year) + " has:")
    print ("Days: " + str(days))
    print ("Hours: " + str(int(days)*24))
    print ("Minutes: " + str((int(days)*24)*60))
    print ("Seconds: " + str(((int(days)*24)*60)*60))


day_hours(2018, False)

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.