From 39b645e0eb80a3e5d6add87c86e9b92f3c3c8547 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Wed, 8 May 2024 12:18:03 -0400 Subject: [PATCH] added ANSI color codes to hypotenuse --- hypotenuse/main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hypotenuse/main.py b/hypotenuse/main.py index 664d776..a862ea1 100644 --- a/hypotenuse/main.py +++ b/hypotenuse/main.py @@ -1,5 +1,10 @@ from math import sqrt +# ANSI color codes +BLUE = "\033[34m" # Blue +RED = "\033[31m" # Red +GREEN = "\033[32m" # Green +RESET = "\033[0m" # Reset to default color def calculate_hypotenuse(x: float, y: float) -> float: x = float(x) @@ -7,10 +12,10 @@ def calculate_hypotenuse(x: float, y: float) -> float: return sqrt(x**2 + y**2) if __name__ == "__main__": - x = input("Input your A: ") - y = input("Input your B: ") + x = input(f"{BLUE}Input your A:{RESET} ") + y = input(f"{BLUE}Input your B:{RESET} ") try: result = calculate_hypotenuse(x,y) - print(f"{round(result)} ({result})") + print(f"{GREEN}{round(result)} ({result}){RESET}") except ValueError: - print("Error! Please do not input strings.") + print(f"{RED}Please do not input strings.{RESET}")