Python Bibliotheca
Python resources for teachers and students.

Temperature converter

Description

Write two functions that will convert temperatures back and forth from the Celsius and Fahrenheit temperature scales. The formulas for making the conversion are as follows:

  Tc=(5/9)*(Tf-32)
  Tf=(9/5)*Tc+32

where Tc is the Celsius temperature and Tf is the Fahrenheit temperature. More information and further descriptions of how to do the conversion can be found at this NASA Webpage. If you finish this assignment quickly, add a function to calculate the wind chill.

Input

Your program should ask the user to input a temperature and then which conversion they would like to perform.

Sample session

Temperature converter

Enter a temperature: 20
Convert to (F)ahrenheit or (C)elsius? F

20 C = 68 F

[ Copyright 2003, Tim Wilson ]

Comments, questions, or suggestions? Email the webmaster