gpt4 book ai didi

python - pyschool 主题 2 中返回的答案错误 : Q 6

转载 作者:行者123 更新时间:2023-11-30 23:04:01 25 4
gpt4 key购买 nike

我正在尝试 PySchools 上的练习,但我陷入了主题:2 Q6。问题如下

Write a function to compute the BMI of a person.

BMI = weight(kg)  /  ( height(m)*height(m) )  

我尝试了这段代码

def BMI(weight, height): 
return "%.1f"%(weight/(height*height))

我得到的结果如下所示

enter image description here

这里有什么问题吗?

最佳答案

操作

weight/(height*height)

返回一个整数(整数)。要将计算作为 float ,请使用 f.ex。

1.0 * weight/(height*height)

关于python - pyschool 主题 2 中返回的答案错误 : Q 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33888170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com