Skip to content

Commit ef8ec43

Browse files
Update decimal_to_fraction.py
1 parent 2bf88ec commit ef8ec43

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

maths/decimal_to_fraction.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,22 @@ def decimal_to_fraction(decimal: float | str) -> tuple[int, int]:
1414
>>> decimal_to_fraction("6.25")
1515
(25, 4)
1616
>>> decimal_to_fraction("78td")
17-
1817
Traceback (most recent call last):
1918
ValueError: Please enter a valid number
2019
>>> decimal_to_fraction(0)
21-
(0,1)
22-
>>>decima_to_fraction(-2.5)
23-
(-5,2)
24-
>>> >>> decimal_to_fraction(0.125)
25-
(1,8)
20+
(0, 1)
21+
>>> decimal_to_fraction(-2.5)
22+
(-5, 2)
23+
>>> decimal_to_fraction(0.125)
24+
(1, 8)
2625
>>> decimal_to_fraction(1000000.25)
27-
(4000001, 400)
26+
(4000001, 4000)
2827
>>> decimal_to_fraction(1.3333)
29-
(133333, 10000)
30-
>>> decimal_to_fraction(1.23e2)
28+
(13333, 10000)
29+
>>> decimal_to_fraction("1.23e2")
3130
(123, 1)
32-
>>> decimal_to_fraction("0.0500")
33-
(1,2)
31+
>>> decimal_to_fraction("0.500")
32+
(1, 2)
3433
"""
3534
try:
3635
decimal = float(decimal)

0 commit comments

Comments
 (0)