You are viewing a single comment's thread. Return to all comments →
Indeed the way to go, here are some print statement might help understand the logic:
print('\nFor year',year,':') print('\tyear%4 =',year%4) print('\tyear%400 =',year%400) print('\tyear%100 =',year%100) print('\nTherefore:') print('\tyear%4 == 0 is',bool(year%4 == 0)) print('\tyear%400 == 0 is',bool(year%400 == 0)) print('\tyear%100 != 0 is',bool(year%100 != 0)) print('\nSo:') print('\tyear%4 == 0 is',bool(year%4 == 0)) print('\tAND') print('\t( year%400 == 0 is',bool(year%400 == 0)) print('\tOR') print('\tyear%100 != 0 is',bool(year%100 != 0),')') print('\nBecomes:') print('\tyear%4 == 0 is',bool(year%4 == 0)) print('\tAND') print('\t(year%400 == 0 or year%100 != 0) is',bool(year%400 == 0 or year%100 != 0)) print('\nWhich brings us to:') print('\t',bool(year%4 == 0),'AND',bool(year%400 == 0 or year%100 != 0),'is',bool(year%4 == 0 and (year%400 == 0 or year%100 != 0))) print()
Seems like cookies are disabled on this browser, please enable them to open this website
Write a function
You are viewing a single comment's thread. Return to all comments →
Indeed the way to go, here are some print statement might help understand the logic: