Conversion code not working properly

weasel healthed at hotmail.com
Sun Feb 22 14:07:01 EST 2004


Why is the Farenheit to Celsius part not working properly? Instead of
showing a similar range of what the farenheit is listing, the celsius
portion is showing half the range of farenheit.

print "\nWelcome to the Temperature program" 

while True:
    low1 = raw_input("Please enter a low temperature: ").upper()
    if low1 != 'I QUIT':
        low = int(low1)
    if low1 == 'I QUIT':
        break

    
    high = int(raw_input("Please enter a high temperature: "))
    temp = raw_input('Please indicate Celsius or Fahrenheit ').upper()

    while not temp or temp not in 'CF':
	temp = raw_input('Please indicate Celsius or Fahrenheit
').upper()
    
    if temp == 'C' and low <= high:
        
        low_other_temp = (9 / 5 * low) + 32
        high_other_temp = (9 / 5 * high) + 32
        rnge = range(low, high + 1)
        faren = range(low_other_temp, high_other_temp + 1)  
        print rnge
        print faren
   
    elif temp == 'F' and low <= high:

        num1 = low - 32
        num2 = high - 32
        low_temp = num1 * 5/9
        high_temp = num2 * 5/9
        rnge = range(low, high + 1)
        celsi = range(low_temp, high_temp + 1)
        print rnge
        print celsi
    
    else:
        print 'Invalid temperatures specified! The low must be less
than the high!'

    exit = raw_input('Hit <enter> to continue. Type " I quit" in the
low temp field to exit.')
    print 'Returning to main.'



More information about the Python-list mailing list