-4

How do you make the exponent cubed in Python while printing.

e.g. print ("3***cubed***")

I don't want to cube the number - I want the sign

Thanks in advance

I want to make this volume calculator:

I want it to print cubed at the end when it tells you the answer:

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"
ComputerXplorer
  • 193
  • 3
  • 4
  • 10
  • I don't understand. Could you give an example. – Colonel Panic Sep 23 '13 at 19:16
  • 3
    possible duplicate of [How do you print superscript in Python?](http://stackoverflow.com/questions/8651361/how-do-you-print-superscript-in-python) – Lorenzo Baracchi Sep 23 '13 at 19:19
  • the `**` operator? `print( 3**3 )` – clcto Sep 23 '13 at 19:19
  • 3
    What's with `2**31 -1`? You do know that integers can get arbitrarily large in Python? Also, what if your user inputs a wrong height three times? – Tim Pietzcker Sep 23 '13 at 19:19
  • sys.maxsize An integer giving the maximum value a variable of type Py_ssize_t can take. It’s usually 2**31 - 1 on a 32-bit platform and 2**63 - 1 on a 64-bit platform. – ComputerXplorer Sep 23 '13 at 19:22
  • 1
    @Discoverer: but `Py_ssize_t` is an implementation detail, one used behind the scenes, and isn't the same as `int` at all. Try `11**1000`, for example, and look at all the digits. Python integers are limited only by available memory. – DSM Sep 23 '13 at 19:23
  • 2
    You're looking for the unicode ['Superscript 3'](http://www.fileformat.info/info/unicode/char/b3/index.htm) character, `³`. If your source encoding supports unicode, you can get it with `u'cm³'`, else you need `u'cm\u00b3'` (if this is python 3, you do not need the leading `u`s) – Eric Sep 23 '13 at 19:26
  • So `print(u"The volume of the cuboid is {}cm\u00b3".format(volume))` – Eric Sep 23 '13 at 19:31
  • 2
    Dang, I was just writing an answer, now it's on hold... To find out how to represent _any_ character in Python, just copy-paste it from somewhere else (e.g. Word) and print its `repr`: `print repr("³")` yields `'\xc2\xb3'` – tobias_k Sep 23 '13 at 19:32

1 Answers1

2

"make the exponent cubed" doesn't make sense. If you want to "cube" a number, that means you want to raise it to the third power. In other words, you want the exponent to be three.

>>> 2**3
8
Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328