The following programs convert from Celsius to Farenheit and vice-versa, respectively. If you don't know where to start, paste the following text in your favorite text editor (such as notepad, if you are a Windows user) and save it as average4.py in a folder that contains other .py programs that work on your computer.
tofarenheit.py
celsius = input("Please enter a Celsius temperature. ")tocelsius.py
farenheit = (celsius * 1.8) + 32
print celsius, "degrees Celsius is equal to " + str(farenheit) + " degrees Farenheit."
farenheit = input("Please enter a Farenheit temperature. ")The program is called from within the interactive interpreter by importing the module, as follows. The program instructs the user on how to proceed.
celsius = (farenheit - 32) * .6
print farenheit, "degrees Farenheit is equal to " + str(celsius) + " degrees Celsius."
>>> import tofarenheit
Please enter a Celsius temperature. 0
0 degrees Celsius is equal to 32.0 degrees Farenheit.
>>>