From b84f62cb59ba2d278ad82734651717e1880481ee Mon Sep 17 00:00:00 2001 From: EntropicDecay Date: Mon, 29 Apr 2024 19:00:23 -0500 Subject: [PATCH] math, division --- .gitea/workflows/config/.pylintrc | 3 ++- division/main.py | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/config/.pylintrc b/.gitea/workflows/config/.pylintrc index 4adb430..87db147 100644 --- a/.gitea/workflows/config/.pylintrc +++ b/.gitea/workflows/config/.pylintrc @@ -4,4 +4,5 @@ missing-module-docstring, missing-function-docstring, missing-class-docstring, - line-too-long + line-too-long, + redefined-outer-name diff --git a/division/main.py b/division/main.py index 6a66a70..b8b29bf 100644 --- a/division/main.py +++ b/division/main.py @@ -1,23 +1,23 @@ # ANSI color codes -blue = "\033[34m" # Blue -red = "\033[31m" # Red -green = "\033[32m" # Green -reset = "\033[0m" # Reset to default color +BLUE = "\033[34m" # Blue +RED = "\033[31m" # Red +GREEN = "\033[32m" # Green +RESET = "\033[0m" # Reset to default color -def divide(x: int, y: int) -> float | None: +def divide(x: float, y: float) -> float | None: try: - x = int(x) - y = int(y) + x = float(x) + y = float(y) except ValueError: - return print(f"{red}You cannot divide by strings!{reset}") + return print(f"{RED}You cannot divide by strings!{RESET}") if y == 0: - return print(f"{red}You cannot divide by 0!{reset}") + return print(f"{RED}You cannot divide by 0!{RESET}") # you don't divide by zero return float(x/y) if __name__ == "__main__": - x = input(f"{blue}Input a number to divide:{reset} ") - y = input(f"{blue}Input a number to divide by:{reset} ") + x = input(f"{BLUE}Input a number to divide:{RESET} ") + y = input(f"{BLUE}Input a number to divide by:{RESET} ") result = divide(x,y) if result is not None: - print(f"{green}{result}{reset}") \ No newline at end of file + print(f"{GREEN}{result}{RESET}") \ No newline at end of file