← Back to challenges

Expand a Number II

PythonHardalgorithmslanguage_fundamentalsmathnumbersarrays

Instructions

Create a function that expands a decimal number into a string as shown below:

25.24 ➞ "20 + 5 + 2/10 + 4/100"
70701.05 ➞ "70000 + 700 + 1 + 5/100"
685.27 ➞ "600 + 80 + 5 + 2/10 + 7/100"

Examples

expanded_form(87.04) ➞ "80 + 7 + 4/100"

expanded_form(123.025) ➞ "100 + 20 + 3 + 2/100 + 5/1000"

expanded_form(50.270) ➞ "50 + 2/10 + 7/100"

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.