我在这段代码的输出中得到了很多小数(华氏到摄氏转换器)。
我的代码当前如下所示:
def main():
printC(formeln(typeHere()))
def typeHere():
global Fahrenheit
try:
Fahrenheit = int(raw_input("Hi! Enter Fahrenheit value, and get it in Celsius!\n"))
except ValueError:
print "\nYour 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 "\nYour Celsius value is " + answer + " C.\n"
main()
所以我的问题是,如何使该程序四舍五入到小数点后第二位?
慕标5151211
慕侠2389804
白衣染霜花
胡说叔叔
相关分类