On Feb 26, 7:14 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote:
> <[EMAIL PROTECTED]> wrote in message
>
> news:[EMAIL PROTECTED]
> | Hi I'm very much a beginner with Python.
> | I want to write a function to convert celcius to fahrenheit like this
> | one:
> |
> | def celciusToFahrenheit(tc):
> |    tf = (9/5)*tc+32
> |    return tf
>
> Unless you are importing 'integer division' or using 3.0, that should be
> 9.0/5.0.

Has the syntax changed? I thought it was:
    from __future__ import division

The OP may wish to avoid the confusion and the pointless division by
using:
   tf = 1.8 * tc + 32


>
> | I want the answer correct to one decimal place, so
> | celciusToFahrenheit(12) would return 53.6.
>
> As written, running above on 2.x returns 44.
>
> tjr

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to