Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.052 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'else:': 0.03; 'syntax': 0.04; 'elif': 0.05; 'logic': 0.09; 'def': 0.12; 'assume': 0.14; '0))': 0.16; 'grounds': 0.16; 'quoted': 0.16; 'soap,': 0.16; 'language': 0.16; 'trying': 0.19; 'print': 0.22; 'cheers,': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'url:wiki': 0.31; 'url:wikipedia': 0.31; 'url:non-standard http port': 0.33; 'problem': 0.35; 'received:66': 0.35; 'except': 0.35; 'something': 0.35; 'there': 0.35; 'false': 0.36; "didn't": 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'anything': 0.39; 'explain': 0.39; 'to:addr:python.org': 0.39; 'received:unknown': 0.61; 'header:Message-Id:1': 0.63; 'charset:windows-1256': 0.64; 'mar': 0.68; '****': 0.68; 'received:204': 0.75; '100': 0.79; 'age.': 0.84; 'algorithm,': 0.84; 'answer:': 0.84; 'fading': 0.84; 'boxes': 0.91 X-Spam-Status: No, score=0.4 required=5.0 X-Spam-Level: From: Gene Heskett To: python-list@python.org Subject: Re: Leap year Date: Sat, 27 Sep 2014 00:08:01 -0400 References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="windows-1256" Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1411791330 news.xs4all.nl 2964 [2001:888:2000:d::a6]:35178 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78399 On Friday 26 September 2014 23:49:43 Seymore4Head did opine And Gene did reply: > 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 > > Me trying to look at the algorithm, it would lead me to try something > like: > if year % 4 !=0: > return False > elif year % 100 !=0: > return True > elif year % 400 !=0: > return False > > **** Since it is a practice problem I have the answer: > def is_leap_year(year): > return ((year % 4) == 0 and ((year % 100) != 0 or (year % 400) == 0)) > > 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") Which is, except for language syntax to state it, exactly the same as is quoted for this problem in the original K&R C manual. Is there anything new? Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS