def main(): print("Which method of conversion would you like to use?") print("1. Fahrenheit to Celcius") print("2. Celcius to Fahrenheit") choice = int(input("Please input a number choice:\n")) if choice in {1}: fahrenheitToCelcius() elif choice in {2}: celciusToFahrenheit() def fahrenheitToCelcius(): f = int(input("Please enter the temperature in Faherenheit: \n")) c = (f - 32.0) * 5.0/9.0 print("The temperature of %i F is %i C") % (f,c) def celciusToFahrenheit(): c = int(input("Please enter the temperature in Celcius: \n")) f = c * 9.0/5.0 + 32.0 print("The temperature of %i C is %i F") % (c,f) main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question