1
1
Fork 0

math, division
Some checks failed
Actions / Lint Code (Ruff & Pylint) (push) Failing after 12s

This commit is contained in:
EntropicDecay 2024-04-29 19:00:23 -05:00
parent 8c07907b6b
commit b84f62cb59
2 changed files with 14 additions and 13 deletions

View file

@ -4,4 +4,5 @@
missing-module-docstring,
missing-function-docstring,
missing-class-docstring,
line-too-long
line-too-long,
redefined-outer-name

View file

@ -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}")
print(f"{GREEN}{result}{RESET}")