1
1
Fork 0

completed division
Some checks failed
Actions / Lint Code (Ruff & Pylint) (push) Failing after 11s

Co-authored-by:
seaswimmerthefsh@gmail.com <seaswimmerthefsh@gmail.com>
This commit is contained in:
EntropicDecay 2024-04-29 18:53:35 -05:00
parent d9b6631b6f
commit 8c07907b6b
2 changed files with 24 additions and 0 deletions

1
division/__init__.py Normal file
View file

@ -0,0 +1 @@
# don't modify this file

23
division/main.py Normal file
View file

@ -0,0 +1,23 @@
# ANSI color codes
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:
try:
x = int(x)
y = int(y)
except ValueError:
return print(f"{red}You cannot divide by strings!{reset}")
if y == 0:
return print(f"{red}You cannot divide by 0!{reset}")
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} ")
result = divide(x,y)
if result is not None:
print(f"{green}{result}{reset}")