Skip to content

Instantly share code, notes, and snippets.

@NotTheEconomist
Last active November 27, 2015 18:08
Show Gist options
  • Save NotTheEconomist/850bcac0ed3a24f13535 to your computer and use it in GitHub Desktop.
Save NotTheEconomist/850bcac0ed3a24f13535 to your computer and use it in GitHub Desktop.
def convert_temp():
'''Prints fahrenheit, celsius, and kelvin temps from user input'''
# helper functions to convert from fahrenheit
def celsius(temp_f):
return (5 / 9) * (temp_f - 32)
def kelvin(temp_f):
return (5 / 9) * (temp_f - 32) + 273.15
f = float(input("Enter a temperature (in Fahrenheit): "))
print("The temperature in Fahrenheit is {}".format(f))
print("The temperature in Celsius is {}".format(celsius(f)))
print("The temperatore in Kelvin is {}".format(kelvin(f)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment