From 09b6a622c7e26c96f54279e5e6e3ea419f6daad3 Mon Sep 17 00:00:00 2001 From: PAUL ADUTWUM Date: Wed, 5 Mar 2025 20:40:14 -0500 Subject: [PATCH] Update decimal_to_fraction.py --- maths/decimal_to_fraction.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/maths/decimal_to_fraction.py b/maths/decimal_to_fraction.py index 2aa8e3c3dfd6..acadea162a9b 100644 --- a/maths/decimal_to_fraction.py +++ b/maths/decimal_to_fraction.py @@ -16,6 +16,18 @@ def decimal_to_fraction(decimal: float | str) -> tuple[int, int]: >>> decimal_to_fraction("78td") Traceback (most recent call last): ValueError: Please enter a valid number + >>> decimal_to_fraction(-2.5) + (-5, 2) + >>> decimal_to_fraction(0.125) + (1, 8) + >>> decimal_to_fraction(1000000.25) + (4000001, 4000) + >>> decimal_to_fraction(1.3333) + (13333, 10000) + >>> decimal_to_fraction("1.23e2") + (123, 1) + >>> decimal_to_fraction("0.500") + (1, 2) """ try: decimal = float(decimal)