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? 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.
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). That's probably not what you want here. You can let Python handle the formatting here:
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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.