在Python中生成指数“cubed”?

2024-09-28 20:53:48 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在打印时使用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"

Tags: thenumberinputifnotwidthlengthint