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


Groups > comp.lang.python > #54667

Re: Help with python functions?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; 'float': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'spec': 0.09; 'subject:Help': 0.11; 'python': 0.11; 'def': 0.12; "('c',": 0.16; '23,': 0.16; '32)': 0.16; '32,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'mon,': 0.24; "i've": 0.25; 'header:X-Complaints-To:1': 0.27; '-0700,': 0.31; "d'aprano": 0.31; 'sep': 0.31; 'steven': 0.31; 'skip:c 30': 0.32; 'monday,': 0.33; 'subject:with': 0.35; 'one,': 0.35; 'version': 0.36; 'next': 0.36; "didn't": 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; "you're": 0.61; 'email addr:gmail.com': 0.63; 'temperature': 0.84; 'wrong...': 0.84; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re: Help with python functions?
Date Tue, 24 Sep 2013 00:07:44 +0000 (UTC)
References <e484b709-1287-4e6a-bc43-05f02a608579@googlegroups.com> <5240489d$0$29992$c3e8da3$5496439d@news.astraweb.com> <3af43a58-fc56-46d1-9e1e-cb69f8aa520b@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 174.32.174.35
User-Agent XPN/1.2.6 (Street Spirit ; Linux)
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.282.1379981286.18130.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1379981286 news.xs4all.nl 15901 [2001:888:2000:d::a6]:51336
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:54667

Show key headers only | View raw


On 23/9/2013 18:55, kjakupak@gmail.com wrote:

> On Monday, September 23, 2013 9:56:45 AM UTC-4, Steven D'Aprano wrote: 
>> On Mon, 23 Sep 2013 05:57:34 -0700, kjakupak wrote: 
>> 
>> Now you're done! On to the next function... 
>> 
>> 
>> 
>> -- 
>> 
>> Steven 
>
> 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? 
> Also, the temperature number had to be of type float so I feel like I did this wrong...
>
> As for the next one, so far I've gotten:
> def comp(T1, u1, T2, u2):
>     if u1 > u2:
>         return -1
>     elif u2 > u1:
>         return 1
>     else:
>         return 0


I didn't see any spec that said Python 3.x.  in version 2.x, this would
be incorrect.

-- 
DaveA

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


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