Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78399
| 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 | <gheskett@wdtv.com> |
| 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 <gheskett@wdtv.com> |
| To | python-list@python.org |
| Subject | Re: Leap year |
| Date | Sat, 27 Sep 2014 00:08:01 -0400 |
| References | <vocc2a17rl5odoasq7ae317aju8de9ejcn@4ax.com> |
| In-Reply-To | <vocc2a17rl5odoasq7ae317aju8de9ejcn@4ax.com> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14410.1411791330.18130.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
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 <http://geneslinuxbox.net:6309/gene>
US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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