Hello, I am very new to Python (just started yesterday) and I've written a program for converting temperatures. I get wrong C to F numbers, and when I try to go from F to C I get 0. Here is the code:

``````choice =1
while choice==1:
print "1. Celcius to Ferenheit"
print "2. Ferenheit to celsius"
print "3. Escape"
if ham==1:
tc=input("Put a celcius temp in: ")
tf=(9/5)*(tc+32)
print tf
if ham==2:
TF=input("Enter a Farenheit temp: ")
TC=(5/9)*(TF-32)
print TC
if ham==3:
choice=0``````
2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by snippsat

As first line use this and it will work.
from __future__ import division

Or.

``````TF = float(raw_input("Enter a Farenheit temp: "))
TC = (5/9.0)*(TF-32) #9.0 make it float``````

As first line use this and it will work.
from __future__ import division

Or.

``````TF = float(raw_input("Enter a Farenheit temp: "))
TC = (5/9.0)*(TF-32) #9.0 make it float``````

Where do you want me to put from__future__import division? I put it as my very first line and got a syntax error.

Solved thanks for the help

Like this and it should work.

``````from __future__ import division

choice =1
while choice==1:
print "1. Celcius to Ferenheit"
print "2. Ferenheit to celsius"
print "3. Escape"