EntropicDecay
8c07907b6b
Some checks failed
Actions / Lint Code (Ruff & Pylint) (push) Failing after 11s
Co-authored-by: seaswimmerthefsh@gmail.com <seaswimmerthefsh@gmail.com>
23 lines
No EOL
662 B
Python
23 lines
No EOL
662 B
Python
# 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}") |