You are viewing a single comment's thread. Return to all comments →
How does the "return year%4==0..." sentence know what you are returning is a boolean? Is that defined by "def is_leap"? Thank you
because all expressions used in that return statement evaluate to booleans
sir,can you give a clear description about return statements
That exactly is not the case. Try to run following code in interpreter:
return (not(year%4) and ((year%100) or not(year%400)))
Invoke it using
It returns 64 instead of True. Thats because the expression (year%100) returns 64
to mitigate that run following code and that returns either True or False:
return (not(year%4) and (bool(year%100) or not(year%400)))
How does that contradict what that guy said? You wrote different code than what he wrote. You're exploiting "truthy/falsey" values; the other guy's just using regular booleans
check again. he also used == signs to evaluate it to a boolean expression.
How it give an boolen value ?
Check out python truthiness