Hey there everyone I need a little help. Right now I am in the process of writing a program that uses subscripts and superscript but I dont have a clue how to get them. I am not even sure if they can be used in python so if any of you could give me a little help I would love it. :)

You need to give more info dude. As far as usage is concerned just look into any python tutorial on WWW

XML handles subscripts and superscripts amongst other things. Look into the module PyXML or wxPython's Fancytext widget.

For a fancytext example see:
http://www.daniweb.com/forums/post643697-23.html

Another way would be to use the richedit format, again wxPython's TextCtrl() widget can handle that.

For superscript you could use:

>>> print '\xb2'
²
>>> print '\xb3'
³

I'm not so sure about subscript though. Just try typing into your interpreter:

>>> a = '<your_character_here>'
>>> a
'\<escaped_version_of_your_character>'

Ok here is my problem more detailed. Lets say I am making a simple program in which I ask the person to type in a number and that number is multiplied my some other number of my choice. Now what I want is to put a subscript or superscript to the new number. How do I do that? Here is an example of the code I just describe:

def N():
a = input("Please enter any number: ");
b = a * 0.00544
print b

Now what I want is that when the program prints b to print a subscript or superscript next to it. The reason I am trying to get the sub/superscripts is that whenever python does a mathematical operation such as 5 * 0.00544 it prints this 0.027200000000000002 which can be simplified as 0.0272x10^18. Hopefully this explain better my little dilemma.

You are mistaking sub/superscript for scientific/exponential notation (P.S. your scientific notation conversion is way off).

>>> '%e' % (5 * 0.00544)
'2.720000e-002'
>>> '%.2e' % (5 * 0.00544)
'2.72e-002'
>>>

That illustrates some text formatting in Python. If you'd like information check out this page on Formatting

thanks that really helped a lot I can finish my program now. BTW my the scientific notation conversion is right since there are 18 numbers after the decimal.

>>> '%e' % (5 * 0.00544)
'2.720000e-002'
>>> '%.2e' % (5 * 0.00544) ## This is the correct form of sci. notation *10^-2
'2.72e-002'
>>> 
>>> 0.0272 * 10**18  ## This is what your number was
27200000000000000.0

You see? Like I said, you were way off. That last one is 10^18

Good news: the convention for scientific notation

2.72e-2 (which is the correct rendering)

is so well-recognized that superscripting is not required.

Jeff

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.