0
# lets calculate the area of a rectangle
length_of_rectangle_1 = 6
breadth_of_rectangle_1 = 10
area_of_rectangle_1 = length_of_rectangle_1 * breadth_of_rectangle_1
print(area_of_rectangle_1)
length_of_rectangle_2 = 12
breadth_of_rectangle_2 = 22
area_of_rectangle_2 = length_of_rectangle_2 * breadth_of_rectangle_2
print(area_of_rectangle_2)

I want to find how to put the little 2 on top of cm

Arav Taneja
  • 31
  • 1
  • 12

1 Answers1

1

In Python you can simply add the Unicode character to the string:

str(100) + 'cm' + '\u00B2'

There are many unicode character tables on the web. The \u part means "this is a Unicode string" ad the '00B2' part is just the hexadecimal code for the symbol. Now, this character is very commonly supported in fonts, but not all fonts, or even ones that claim to support Unicode, have all characters. Hope this helps!

TomServo
  • 7,248
  • 5
  • 30
  • 47