Standard Form Conversion Algorithm

standard-formStandard form (a.k.a. standard index form), is a system of writing numbers which is particularly useful when using either very large or very small numbers. It is based on using powers of 10 to express how big or small a number is.

Standard form is written in the form of a x 10n, where is a number between 1 and 10 (bigger than or equal to 1 but strictly lower than 10). For large numbers, n is a positive whole number, whereas for small numbers, n is negative whole number.


The standard form is for instance used by astronomers as the distance between stars is very high, resulting in numbers which are not easy to write down and memorise without using the standard form. For instance did you know that Alpha Centauri was the second nearest planet (after the Sun) to planet Earth. It is located 4.37 light-years away from the Sun. Considering that a light-year is the distance travelled by light in one year and knowing that light travels at 300,000 km per second we can work out the distance in km between Alpha Centauri and the Sun as follows:

4.37 light-years = 4.37 x 365.25 x 24 x 60 x 60 x 300,000 ≈ 41,400,000,000,000 km

In standard form:
4.14 x 1013 km

h2o-moleculeSimilarly, physicists and chemists use the standard form when using very small numbers. For instance, the size of a molecule of water (H2O) is about 0.27 of a nanometer.

0.27 nanometers = 0.00000000027 meters

In standard form:
2.7 x 10-10 meters

Programming Challenge

Our aim is to write a procedure that takes a number as a parameter and outputs this number in standard form. To do so, our procedure will be based on the following algorithm:

Python Code

Complete the python code using the trinket below:

Test Plan

All done? It’s now time to test your code to see if it works as expected.

Test # Input Values Description Expected Output Actual Output
#1 41400000000000 The distance (in km) between the Sun and Alpha Centauri 4.14 x 1013
#2 0.00000000027 The size (in meters!) of a molecule of water. 2.7 x 10-10
#3 5972000000000000000000000 The mass (in kg) of planet Earth 5.972 × 1024
#4 1898000000000000000000000000 The mass (in kg) of Jupiter 1.898 × 1027


The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 4.3 / 5. Vote count: 17

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: , ,