Jump to content

Leap Year

- - - - -

  • Please log in to reply
1 reply to this topic

#1
restin84

restin84

    Learning Programmer

  • Members
  • PipPipPip
  • 53 posts
Simple leap year calculator just wondering if the logic is good. All the numbers I've tested so far have worked out


def LeapYear(year):
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
return True

#2
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 890 posts
  • Location:::1
Seems good. You can test it with calendar module, it has a isleap method.
import calendar
print calendar.isleap(1900)

A conclusion is where you got tired of thinking.
#define class struct    // All is public.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users