Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

temp converter - Python Code Bank


temp converter
just does converts Celsius to Fahrenheit and vice versa. cant do decimals. working on it.
                print "###############" # making it look pretty
print "# Temperature #"
print "# Conversion  #"
print "###############"
print "no decimals '.'"
print ""
print ""
num = int(raw_input("enter tempurature to convert ")) # gets the tempurature
string = raw_input("what scale is the number ") # gets what scale the number is on
if string == "c":
____sum = 1.8*num+32 # doesnt work with ()'s
____print sum
elif string == "f":
____sum = (0.56)*(num-32) # doesnt work without ()'s
____print sum
else:
____print "wrong scale"
            
Comments
ghost's avatar
ghost 15 years ago

sorry about the underscores. i wasnt sure if the codebank supported white space or not.

ynori7's avatar
ynori7 15 years ago

It does.

ynori7's avatar
ynori7 15 years ago

For decimal support, use float() instead of int()

ghost's avatar
ghost 15 years ago

thanks