Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54709
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.mixmin.net!weretis.net!feeder4.news.weretis.net!storethat.news.telefonica.de!feedme.news.telefonica.de!telefonica.de!diesel.cu.mi.it!.POSTED!not-for-mail |
|---|---|
| From | giacomo boffi <pecore@pascolo.net> |
| Newsgroups | comp.lang.python |
| Subject | Re: Help with python functions? |
| Date | Tue, 24 Sep 2013 18:53:36 +0200 |
| Organization | The Sun and the Rain. |
| Lines | 24 |
| Message-ID | <87txhap3e7.fsf@pascolo.net> (permalink) |
| References | <e484b709-1287-4e6a-bc43-05f02a608579@googlegroups.com> <5240489d$0$29992$c3e8da3$5496439d@news.astraweb.com> <66aa7d75-a819-4b21-9f1e-7ad265996150@googlegroups.com> |
| NNTP-Posting-Host | host189-21.stru.polimi.it |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | virtdiesel.mng.cu.mi.it 1380041617 18034 131.175.189.21 (24 Sep 2013 16:53:37 GMT) |
| X-Complaints-To | abuse@diesel.cu.mi.it |
| NNTP-Posting-Date | Tue, 24 Sep 2013 16:53:37 +0000 (UTC) |
| User-Agent | Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.5-b32 (linux) |
| Cancel-Lock | sha1:OhADttTndhwATCpGoh96OUfhaBI= |
| Xref | csiph.com comp.lang.python:54709 |
Show key headers only | View raw
kjakupak@gmail.com writes:
> def temp(T, from_unit, to_unit):
> conversion_table = {('c', 'k'):lambda x: x + 273.15,
> ('c', 'f'):lambda x: (x * (9.0/5)) + 32,
> ('k', 'c'):lambda x: x - 273.15,
> ('k', 'f'):lambda x: (x * (9.0/5)) - 459.67,
> ('f', 'c'):lambda x: (x - 32) * (5.0/9),
> ('f', 'k'):lambda x: (x + 459.67) * (5.0/9)}
> f = conversion_table[(from_unit.lower(), to_unit.lower())]
> return f(T)
>
> Would this be correct?
not always:
>>> temp(-300.0, 'c', 'k')
-26.850000000000023
>>>
--
le mie sacrosante questioni di principio
VS gli sciocchi puntigli di quel cretino del mio vicino
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Help with python functions? kjakupak@gmail.com - 2013-09-23 05:57 -0700
Re: Help with python functions? Roy Smith <roy@panix.com> - 2013-09-23 09:11 -0400
Re: Help with python functions? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-23 13:56 +0000
Re: Help with python functions? kjakupak@gmail.com - 2013-09-23 15:32 -0700
Re: Help with python functions? Terry Reedy <tjreedy@udel.edu> - 2013-09-23 18:48 -0400
Re: Help with python functions? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-24 03:08 +0000
Re: Help with python functions? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-24 03:17 +0000
Re: Help with python functions? giacomo boffi <pecore@pascolo.net> - 2013-09-24 18:53 +0200
Re: Help with python functions? MRAB <python@mrabarnett.plus.com> - 2013-09-24 18:18 +0100
Re: Help with python functions? kjakupak@gmail.com - 2013-09-23 15:55 -0700
Re: Help with python functions? Dave Angel <davea@davea.name> - 2013-09-24 00:07 +0000
Re: Help with python functions? kjakupak@gmail.com - 2013-09-23 18:23 -0700
Re: Help with python functions? Dave Angel <davea@davea.name> - 2013-09-24 03:52 +0000
Re: Help with python functions? Denis McMahon <denismfmcmahon@gmail.com> - 2013-09-24 02:12 +0000
Re: Help with python functions? kjakupak@gmail.com - 2013-09-23 19:40 -0700
Re: Help with python functions? Denis McMahon <denismfmcmahon@gmail.com> - 2013-09-24 14:51 +0000
Re: Help with python functions? Denis McMahon <denismfmcmahon@gmail.com> - 2013-09-24 19:42 +0000
Re: Help with python functions? kjakupak@gmail.com - 2013-10-01 10:53 -0700
Re: Help with python functions? random832@fastmail.us - 2013-10-01 15:02 -0400
Re: Help with python functions? Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-01 21:45 +0000
Re: Help with python functions? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-01 19:19 -0400
Re: Help with python functions? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-24 03:15 +0000
Re: Help with python functions? Denis McMahon <denismfmcmahon@gmail.com> - 2013-09-24 15:02 +0000
csiph-web