[Tutor] Leap years

ahimsa ahimsa@onetel.net.uk
Tue Jan 14 16:51:27 2003


Hello
It's me again ...

On Mon, 2003-01-13 at 11:39, Danny Yoo wrote:
> Hi Don,
> 
> But even better than explicitely returning True or False is to avoid using
> the 'if' statement altogether.  The pseudocode above can be written like
> this:
> 
> ###
> def isLeapYear(year):
>     return (year passes test for a leap year)
> ###
> 
> That is, if we're going to do something like:
> 
>    if something is true:
>        return true
>    else:
>        return false
> 
> it's usually an improvement to be direct and just say
> 
>     return (something is true)
> 
> which is concise and avoids the controversy of using 0/1/True/False
> altogether.  *grin*
> 
But ... how does one construct the test of whether something is true or
not without the test to establish that, which is what the 'if-else'
block was intended to do?

Puzzled ... :)

Andrew