diff --git a/calc.py b/calc.py index 1de5f15..4c48396 100644 --- a/calc.py +++ b/calc.py @@ -1,25 +1,25 @@ def main(): print("Welcome to the Calculator") - command = input("Select command: + or *\nType exit if u want exit \n") + command = input("Select command: [ + ] [ - ] [ * ] [ / ] \nType exit if u want exit \n") match command: case "+": summ() - main() case "*": multiplication() - main() + case "minus": + minus() case "exit": exit case _: print(KeyError("Incorrect")) main() def summ(): - print("Enter number to sum, enter space to finish") + print("Enter number(s) to sum, enter space to calculate") total = 0 while True: num_input = input() if num_input == " ": - print (total) + print (f"Total summ = {total}") main() try: number = float(num_input) @@ -27,8 +27,22 @@ def summ(): print(f"Total summ = {total}") except ValueError: print("Error, enter correct number") +def minus(): + print("Enter number(s) to minus, enter spase to calculate") + total = 0 + while True: + num_input = input() + if num_input == " ": + print(total) + main() + try: + number = float(num_input) + total -= number + print(f"Total minus = {total}") + except ValueError: + print("Error, enter correct number") def multiplication(): - print("Enter number to multiplication, enter space to finish") + print("Enter number to multiplication, enter space to calculate") total = 0 while True: num_input = input()