Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4fbd350

Browse files
PaulAdutwumpre-commit-ci[bot]MaximSmolskiy
authored
Improved test coverage in decimal_to_fraction.py (#12608)
* Imporved test coverage in decimal_to_fraction.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update decimal_to_fraction.py * Update decimal_to_fraction.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
1 parent a415a95 commit 4fbd350

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎maths/decimal_to_fraction.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ 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(0)
20+
(0, 1)
21+
>>> decimal_to_fraction(-2.5)
22+
(-5, 2)
23+
>>> decimal_to_fraction(0.125)
24+
(1, 8)
25+
>>> decimal_to_fraction(1000000.25)
26+
(4000001, 4)
27+
>>> decimal_to_fraction(1.3333)
28+
(13333, 10000)
29+
>>> decimal_to_fraction("1.23e2")
30+
(123, 1)
31+
>>> decimal_to_fraction("0.500")
32+
(1, 2)
1933
"""
2034
try:
2135
decimal = float(decimal)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /