Created
January 30, 2015 01:29
-
-
Save bolenton/880c8fc55b19de9660fd to your computer and use it in GitHub Desktop.
Fehrenheit to Celsius.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#this script will convert fahrenheit to celsius | |
def fahrenheit_to_celsius(cel): | |
f = cel*9/5+32 | |
return f | |
def celsius_to_fahrenheit(fah): | |
c = (fah-32)*5/9 | |
return int(c) | |
def f_c(): | |
print "Lets convert Fahrenheit & Celsius!\n" | |
print "To convert Celsius to Fahrenheit type F" | |
print "To convert Fahrenheit to Celsius type C" | |
print "_______________________________________" | |
choice = raw_input().upper() | |
if choice == 'C': | |
print('Enter Celsius amount you want converted to Fahrenheit') | |
celsius = int(raw_input()) | |
print "{} Celsius is {} Fahrenheit".format(celsius, celsius_to_fahrenheit(celsius)) | |
print "______________________________________________________" | |
elif choice == 'F': | |
print('Enter Fahrenheit amount you want converted to Celcius') | |
fahrenheit = int(raw_input()) | |
print("{} Fahrenheit is {} Celsius".format(fahrenheit, fahrenheit_to_celsius(fahrenheit))) | |
print "______________________________________________________" | |
else: | |
print('not a valid entry') | |
f_c() | |
f_c() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment