[英]I can't undersrand how to divide with brackets and input results
BaseLength = int ( input ("Enter Base Length") )
BaseWidth = int ( input ("Enter A Base Width: ")
PyramidHeight: = int ( input ("Enter Pyramid Height: ")
print (int ( BaseLength*BaseWidth*PyramidHeight/3))
How do I use the input
results in the equation?如何在方程式中使用
input
结果? I am just starting and also young, please be nice.我刚开始,还年轻,请多多关照。
Welcome to Stack Overflow!欢迎来到堆栈溢出!
A couple of missing brackets and such, first fix:几个丢失的括号等,首先修复:
BaseLength = int ( input ("Enter Base Length: ") )
BaseWidth = int ( input ("Enter A Base Width: ") )
PyramidHeight = int ( input ("Enter Pyramid Height: ") )
print(int ( BaseLength*BaseWidth*PyramidHeight/3))
Note that in particular the second and third lines of code are missing a bracked: the int() function is opened but never closed, which Python was likely complaining about.请注意,特别是第二行和第三行代码缺少一个括号: int() function 已打开但从未关闭,这可能是 Python 抱怨的。
Also the int() cast at the end will round down the result of your expression: eg int((1*1*1)/3) = int(0.33333...) = 0
(to force the result to be an integer (round number) and not a number with decimals).最后的 int() 强制转换将舍入表达式的结果:例如
int((1*1*1)/3) = int(0.33333...) = 0
(强制结果为 integer (整数)而不是带小数的数字)。 That's probably not what you want here.这可能不是你想要的。 You can let Python handle the formatting here:
您可以让 Python 在这里处理格式:
BaseLength = int ( input ("Enter Base Length: ") )
BaseWidth = int ( input ("Enter A Base Width: ") )
PyramidHeight = int ( input ("Enter Pyramid Height: ") )
print(BaseLength*BaseWidth*PyramidHeight/3)
Let me know if you have any issues.如果您有任何问题,请告诉我。 Happy coding!
快乐编码!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.