Skip to content

Commit 18e85ea

Browse files
authored
Contributed to test coverage in decimal_to_fraction.py
1 parent fff34ed commit 18e85ea

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

maths/decimal_to_fraction.py

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ def decimal_to_fraction(decimal: float | str) -> tuple[int, int]:
1616
>>> decimal_to_fraction("78td")
1717
Traceback (most recent call last):
1818
ValueError: Please enter a valid number
19+
>>> decimal_to_fraction(-2.5)
20+
(-5, 2)
21+
>>> decimal_to_fraction(0.125)
22+
(1, 8)
23+
>>> decimal_to_fraction(1000000.25)
24+
(4000001, 4000)
25+
>>> decimal_to_fraction(1.3333)
26+
(13333, 10000)
27+
>>> decimal_to_fraction("1.23e2")
28+
(123, 1)
29+
>>> decimal_to_fraction("0.500")
1930
"""
2031
try:
2132
decimal = float(decimal)

0 commit comments

Comments
 (0)