-4

打印时如何在 Python 中使指数立方。

例如print ("3***cubed***")

我不想把数字立方计算 - 我想要符号

提前致谢

我想做这个体积计算器:

当它告诉你答案时,我希望它在最后打印立方体:

height = input("Enter the height: ")
if int(height) <0:
    print("Please enter a number larger than 0")
    height = input("Enter the height: ")
if not int(height) < 2**31 - 1:
    print("You have not entered a number")
    height = input("Enter the height: ")
height = int(height)

width = input("Enter the width: ")
if int(height) <0:
    print("Please enter a number larger than 0")
    height = input("Enter the height: ")
if not int(height) < 2**31 - 1:
    print("You have not entered a number")
    height = input("Enter the height: ")
width = int(width)

length = input("Enter the length: ")
if int(length) <0:
    print("Please enter a number larger than 0")
    length = input("Enter the height: ")
if not int(length) < 2**31 - 1:
    print("You have not entered a number")
    length = input("Enter the length: ")
length = int(length)

volume = height*width*length

print ("The volume of the cuboid is" + str(volume) +"cm"
4

1 回答 1

2

"make the exponent cubed"没有意义。如果你想“立方”一个数字,那就意味着你想把它提升到三次方。换句话说,您希望指数为 3。

>>> 2**3
8
于 2013-09-23T19:17:46.160 回答