•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 423,093 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,340 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 389 | Replies: 8 | Solved
![]() |
•
•
Join Date: Jun 2008
Location: Fort Lauderdale - Florida
Posts: 19
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,461
Reputation:
Rep Power: 10
Solved Threads: 176
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 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.
Last edited by vegaseat : Jul 9th, 2008 at 10:22 am. Reason: example url
May 'the Google' be with you!
For superscript you could use:
I'm not so sure about subscript though. Just try typing into your interpreter:
python Syntax (Toggle Plain Text)
>>> print '\xb2' ² >>> print '\xb3' ³
python Syntax (Toggle Plain Text)
>>> a = '<your_character_here>' >>> a '\<escaped_version_of_your_character>'
•
•
Join Date: Jun 2008
Location: Fort Lauderdale - Florida
Posts: 19
Reputation:
Rep Power: 1
Solved Threads: 0
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.
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.
Last edited by Scuppery : Jul 9th, 2008 at 1:41 pm.
You are mistaking sub/superscript for scientific/exponential notation (P.S. your scientific notation conversion is way off).
That illustrates some text formatting in Python. If you'd like information check out this page on Formatting
python Syntax (Toggle Plain Text)
>>> '%e' % (5 * 0.00544) '2.720000e-002' >>> '%.2e' % (5 * 0.00544) '2.72e-002' >>>
Let's Go Pens!
** Just because I reply to your question does not invite you to PM me. Keep discussions on the thread of topic, I will not answer your questions over PM. **
** Just because I reply to your question does not invite you to PM me. Keep discussions on the thread of topic, I will not answer your questions over PM. **
•
•
Join Date: Jun 2008
Location: Fort Lauderdale - Florida
Posts: 19
Reputation:
Rep Power: 1
Solved Threads: 0
python Syntax (Toggle Plain Text)
>>> '%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
Let's Go Pens!
** Just because I reply to your question does not invite you to PM me. Keep discussions on the thread of topic, I will not answer your questions over PM. **
** Just because I reply to your question does not invite you to PM me. Keep discussions on the thread of topic, I will not answer your questions over PM. **
![]() |
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- delphi word (Pascal and Delphi)
- Help... (JavaScript / DHTML / AJAX)
- Confused & frustrated (Web Developers' Lounge)
- Inserting special characters & superscript (MySQL)
Other Threads in the Python Forum
- Previous Thread: Class getters and setters
- Next Thread: Using PyUsb library in python 2.2



Linear Mode