I have just completed my first programme with help from yourselves.
I cant understand why the code , if x ==1 or 2, wouldn't work in my programme below
# Convert C to F or F to C and return with result select = True while select: x = int(raw_input ('To convert Celsius to Farenheit, enter 1\nTo convert Farenheit to Celsius, enter 2\n')) if x == 1 or x == 2: select = False else: print 'Only options are 1 or 2' #Convert C to F if x == 1: def Tc_to_Tf (): Tc = input ("What is the Celsius Temperature ? " ) Tf = 9.0/5.0 * Tc + 32 return Tf Tf = Tc_to_Tf () #.2f instructs Python that placeholder holds float number with 2decimal places. print 'The temperature is %.2f Degrees Fahrenheit' %(Tf, ) #Convert F to C if x == 2: def Tf_to_Tc (): Tf = input ("What is the Fahrenheit Temperature ? " ) Tc = (5.0/9.0)*(Tf - 32) return Tc Tc = Tf_to_Tc () print 'The temperature is %.2f Degrees Celsius' %(Tc, )
Many thanks in anticipation. I included the whole programme as I would value any comments on my methods.