I am getting a lot of decimals in the output of this code (Fahrenheit to Celsius converter).
My code currently looks like this:
def main():
printC(formeln(typeHere()))
def typeHere():
global Fahrenheit
try:
Fahrenheit = int(raw_input("Hi! Enter Fahrenheit value, and get it in Celsius!
"))
except ValueError:
print "
Your insertion was not a digit!"
print "We've put your Fahrenheit value to 50!"
Fahrenheit = 50
return Fahrenheit
def formeln(c):
Celsius = (Fahrenheit - 32.00) * 5.00/9.00
return Celsius
def printC(answer):
answer = str(answer)
print "
Your Celsius value is " + answer + " C.
"
main()
So my question is, how do I make the program round every answer to the 2nd decimal place?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…