1
1
Fork 0

Merge branch 'master' of https://www.coastalcommits.com/SeaswimmerTheFsh/PythonLearning
Some checks failed
Actions / Lint Code (Ruff & Pylint) (push) Failing after 11s

This commit is contained in:
EntropicDecay 2024-05-08 11:18:18 -05:00
commit 3976c7d8bc

View file

@ -1,5 +1,10 @@
from math import sqrt 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: def calculate_hypotenuse(x: float, y: float) -> float:
x = float(x) x = float(x)
@ -7,10 +12,10 @@ def calculate_hypotenuse(x: float, y: float) -> float:
return sqrt(x**2 + y**2) return sqrt(x**2 + y**2)
if __name__ == "__main__": if __name__ == "__main__":
x = input("Input your A: ") x = input(f"{BLUE}Input your A:{RESET} ")
y = input("Input your B: ") y = input(f"{BLUE}Input your B:{RESET} ")
try: try:
result = calculate_hypotenuse(x,y) result = calculate_hypotenuse(x,y)
print(f"{round(result)} ({result})") print(f"{GREEN}{round(result)} ({result}){RESET}")
except ValueError: except ValueError:
print("Error! Please do not input strings.") print(f"{RED}Please do not input strings.{RESET}")