Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78407

Re:Leap year

From Dave Angel <davea@davea.name>
Subject Re:Leap year
Date 2014-09-27 05:07 -0400
Organization news.gmane.org
References <vocc2a17rl5odoasq7ae317aju8de9ejcn@4ax.com>
Newsgroups comp.lang.python
Message-ID <mailman.14420.1411808694.18130.python-list@python.org> (permalink)

Show all headers | View raw


Seymore4Head <Seymore4Head@Hotmail.invalid> Wrote in message:
> Still practicing.  Since this is listed as a Pseudocode, I assume this
> is a good way to explain something.  That means I can also assume my
> logic is fading with age.
> http://en.wikipedia.org/wiki/Leap_year#Algorithm
> 
<cut>
> 
> I didn't have any problem when I did this:
> 
> if year % 400 == 0:
> 	print ("Not leap year")
> elif year % 100 == 0:
> 	print ("Leap year")
> elif year % 4 == 0:
> 	print ("Leap year")
> else:
> 	print ("Not leap year")
> 

But the first two prints are incorrect, so I'm not sure what you
 mean by "didn't have any problem."

Incidentally, it's usually easier to test a function that does one
 thing. So if you replace all those prints with appropriate return
 True or return False, then it's easy to exhaustively compare two
 variations. 

-- 
DaveA

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Leap year Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-26 23:49 -0400
  Re: Leap year Gene Heskett <gheskett@wdtv.com> - 2014-09-27 00:08 -0400
  Re:Leap year Dave Angel <davea@davea.name> - 2014-09-27 05:07 -0400
  Re: Leap year Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-28 16:22 +1000
  Re: Leap year Rustom Mody <rustompmody@gmail.com> - 2014-09-28 23:58 -0700
    Re: Leap year wxjmfauth@gmail.com - 2014-09-29 01:27 -0700
    Re: Leap year wxjmfauth@gmail.com - 2014-09-29 08:05 -0700

csiph-web