实际上我不知道如何正确地提出这个问题,所以让我告诉你我的家庭作业是什么。。。你知道吗
“他们有直径从0.25米到8米的洞(挖隧道),大小增加了0.25米(0.25,0.5,0.75…7.75,8)。你知道吗
At a minimum, your application will:
-Ask the user for the minimum required volume of the tunnel
-Ask the user for the exact length of the tunnel
-Use a loop to determine the bore-size required as well as the exact volume that would be produced with that bore.
额外学分:
-Tell the user to extend the tunnel if the bore size required is greater than 8m.
-Allow the user to determine the volume of the tunnel with a given bore size and tunnel length
-Allow the user to determine the length of the tunnel with a given bore size and volume (in case the user would prefer to get an exact volume but is flexible with the tunnel length.)
-Provide the user with a list of alternatively shaped prisms (and their dimensions) that could fit the volume and length requirements."
我试过这个,但看起来不对
from math import sqrt
a = float(input("What is the minimum volume that is required? (cubic metres): "))
b = float(input("How long do you need the tunnel to be? (metres): "))
pi = 3.14
r = sqrt(a/pi/b)
c = round(r, 2)
print(c)
对于a=250
和b=12
的输入,当答案(假设)是2.75时,它提供了2.58的输出
我在想,你是怎么把2.58分调到2.75分的,如果你有时间的话,你对如何做额外的功能部分有什么想法/帮助/提示吗?你知道吗
您可以使用循环来检查哪个元素高于某个值,并在达到该值后停止。一般来说,应该是这样的:
相关问题 更多 >
编程相关推荐