This is my first program to convert temperatures. I have a very basic knowledge of Python and I tried using only what I already knew to make the program. What are some improvements I can make, or how can I re-create this in an easier way?
temp_string = raw_input("What is the Temperature: ")
x = int(temp_string)
print x
temp_type = raw_input("Would you like to convert to Celsius or Fahrenheit?: ")
input_type = str(temp_type)
def convert_fahrenheit(x):
x = (x - 32) * 0.556
print x
def convert_celsius(x):
x = (x * 1.8) + 32
print x
if input_type == str("c"):
convert_fahrenheit(x)
elif input_type == str("celsius"):
convert_fahrenheit(x)
elif input_type == str("Celsius"):
convert_fahrenheit(x)
elif input_type == str("C"):
convert_celsius(x)
elif input_type == str("f"):
convert_celsius(x)
elif input_type == str("fahrenheit"):
convert_celsius(x)
elif input_type == str("Fahrenheit"):
convert_celsius(x)
elif input_type == str("F"):
convert_celsius(x)
else:
print "You have not entered a valid conversion"
This is my first program to convert temperatures. I have a very basic knowledge of python and I tried using only what I already knew to make the program. What are some improvements I can make, or how can I re-create this in an easier way?
Thanks guys!