Oct-17-2020, 12:31 AM
There is shorter and arguably simple way to determine leap year:
Python first evaluates 'and' (which is first part of 'or' clause): is year divisible by four and not divisible by 100. If so - it's leap year (True). However, if 'and' evaluates to False second part of 'or' clause is evaluated which checks whether year is divisible by 400 (if year is divisible by 400 it is divisible by four as well)
if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
Python first evaluates 'and' (which is first part of 'or' clause): is year divisible by four and not divisible by 100. If so - it's leap year (True). However, if 'and' evaluates to False second part of 'or' clause is evaluated which checks whether year is divisible by 400 (if year is divisible by 400 it is divisible by four as well)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.