Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

How to convert numbers into SI unit numbers?

Okay so i have an assignment and I need to convert numbers into SI units.

For example

1212131A into 1.21MA

or

0.334A into 3.34mA

thanks
Just simple calculate it: 1212131A / 100 = 1.21MA
0.334A * 10 = 3.34mA

Or what exacly do you mean?

-Zapfen
(May 9, 2013 06:15 AM)Echoe Wrote:  Okay so i have an assignment and I need to convert numbers into SI units.

For example

1212131A into 1.21MA

o

0.334A into 3.34mA

thanks

By any Chance do you go to Grace?

-Chain
(May 12, 2013 03:12 AM)zapfen Wrote:  Just simple calculate it: 1212131A / 100 = 1.21MA
0.334A * 10 = 3.34mA

Or what exacly do you mean?

-Zapfen

Jump. From nearest. Building.

Anyone with some common sense?
Using string or list operations detect the last two characters which will be unit of the quantity.
Like this
Code
import string

figure = raw_input('enter a figure with its unit: ')
unit = ''
for letter in figure:
    if letter in string.ascii_letters:
     unit += letter
print unit

run this code, it will detect unit from the entered figure
This is the output
Code
>>>
enter a figure with its unit: 1.5mV
mV
>>>

It does not detect abbreviations for 'micro'(μ),'ohm'(Ω) etc.. you can add them and form a character map

After extracting the unit from the entered figure write a program to convert it to a target unit based on SI standards.
(May 12, 2013 02:34 PM)Echoe Wrote:  Jump. From nearest. Building.

Anyone with some common sense?

cmon, then ask questions which make sense, damn or should i gues what you want to know?
(May 12, 2013 02:34 PM)Echoe Wrote:  Jump. From nearest. Building.

Anyone with some common sense?

Why should we help you when you act like a dick to anyone that answers?
(May 13, 2013 11:49 AM)Poppins Wrote:  Why should we help you when you act like a dick to anyone that answers?

Uh he was clearly being stupid.. ? -_-
(May 14, 2013 12:32 AM)Echoe Wrote:  Uh he was clearly being stupid.. ? -_-

No he wasn't. That's the correct answer actually.
Hum no it's not. If he wasn't then he must of misunderstood what I was asking, and how can you tell me it's the correct answer to my question when it's me who is asking it?

I'm sorry but don't bother commenting again and don't be an ass and neg rep like a lil bitch. It was a misunderstanding
(May 14, 2013 03:32 AM)Echoe Wrote:  Hum no it's not. If he wasn't then he must of misunderstood what I was asking, and how can you tell me it's the correct answer to my question when it's me who is asking it?

I'm sorry but don't bother commenting again and don't be an ass and neg rep like a lil bitch. It was a misunderstanding

You asked how to convert the specified units to the values provided. If you plug your values into his script, you get the answer you were looking for.
(May 14, 2013 04:13 AM)Poppins Wrote:  You asked how to convert the specified units to the values provided. If you plug your values into his script, you get the answer you were looking for.

This ^. Avoid being pissy when asking for help, and you can avoid -9 rep.
(May 9, 2013 06:15 AM)Echoe Wrote:  Okay so i have an assignment and I need to convert numbers into SI units.

For example

1212131A into 1.21MA

o

0.334A into 3.34mA

thanks

By the way A(ampere) is an SI unit , you said that you need to convert numbers to SI.
In the example you did just the opposite.

Are you asking for a converter...


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by cryptobassboostFeb 7, 2019 05:28 PM 4 219 Feb 7, 2019 05:28 PM
Last Post: Caliban
[Python] by astanoAug 16, 2018 07:50 AM 0 97 Aug 16, 2018 07:50 AM
Last Post: astano
[Java] by SIM-1947090Nov 27, 2017 01:13 AM 4 153 Nov 27, 2017 01:13 AM
Last Post: SIM-1947090