用户输入KGs (例如1800),该KGs应该转换为立方米,并且函数应该返回结果。
这是我的密码:
def volume_per_container(kg_cargo_per_cubic_metre):
"""Given the kg of cargo per cubic metre, calculate how many cubic metres
of cargo can be stored in a single container."""
max_volume_cubic_metres = 65.7
max_net_load = 26199
cubic_metre = kg_cargo_per_cubic_metre / max_net_load
if cubic_metre >= 65.7:
return volume_per_container (kg_cargo_per_cubic_metre) == max_volume_cubic_metres
else:
return volume_per_container (kg_cargo_per_cubic_metre) == cubic_metre我知道这个错误:
RecursionError:比较超过最大递归深度
我怎样才能解决这个问题?
发布于 2020-05-25 15:28:24
你想这样做吗?
def volume_per_container(kg_cargo_per_cubic_metre):
"""Given the kg of cargo per cubic metre, calculate how many cubic metres
of cargo can be stored in a single container."""
max_volume_cubic_metres = 65.7
max_net_load = 26199
cubic_metre = kg_cargo_per_cubic_metre / max_net_load
if cubic_metre >= max_volume_cubic_metres:
return cubic_metre - max_volume_cubic_metres
else:
print("this much left to fill")
return max_volume_cubic_metres - cubic_metrehttps://stackoverflow.com/questions/62005403
复制相似问题