当我在http://www.pyschools.com/quiz/view_question/s2-q1中执行此代码时.它给出了答案的错误......请帮助问题是:
Write a function to convert temperature from Celsius to Fahrenheit scale.
oC to oF Conversion: Multipy by 9, then divide by 5, then add 32.
Examples
>>> Cel2Fah(28.0)
'82.40'
>>> Cel2Fah(0.00)
'32.00'
Run Code Online (Sandbox Code Playgroud)
# Note: Return a string of 2 decimal places.
def Cel2Fah(temp):
x = 9.00
y = 5.00
z = 32.00
a = temp * x
a = a / y
a = a + z
return(a)
Run Code Online (Sandbox Code Playgroud)
在顶部它说:
# Note: Return a string of 2 decimal places.
Run Code Online (Sandbox Code Playgroud)
你没有返回一个字符串.您正在返回类型的值float.
由于这看起来像家庭作业,我会让你弄清楚如何解决这个问题(提示:使用字符串格式化操作符).