From 36990717e87fa0f2804b6f3eebaf50884606f3a1 Mon Sep 17 00:00:00 2001 From: BuravovA Date: Fri, 7 Nov 2025 18:10:44 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=BE=20=D1=87=D1=82=D0=BE=20=D1=83?= =?UTF-8?q?=D1=81=D0=BF=D0=B5=D0=BB=D0=B8=20=D0=BD=D0=B0=20=D0=BF=D0=B0?= =?UTF-8?q?=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- calc.py | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/calc.py b/calc.py index 6f0b857..1de5f15 100644 --- a/calc.py +++ b/calc.py @@ -1,2 +1,45 @@ -print("world says hallo") -print("hello to worlds") \ No newline at end of file +def main(): + print("Welcome to the Calculator") + command = input("Select command: + or *\nType exit if u want exit \n") + match command: + case "+": + summ() + main() + case "*": + multiplication() + main() + case "exit": + exit + case _: + print(KeyError("Incorrect")) + main() +def summ(): + print("Enter number to sum, enter space to finish") + total = 0 + while True: + num_input = input() + if num_input == " ": + print (total) + main() + try: + number = float(num_input) + total += number + print(f"Total summ = {total}") + except ValueError: + print("Error, enter correct number") +def multiplication(): + print("Enter number to multiplication, enter space to finish") + total = 0 + while True: + num_input = input() + if num_input == " ": + print (total) + main() + try: + number = float(num_input) + total *= number + print(f"Total multiplication = {total}") + except ValueError: + print("Error, enter correct number") +if __name__ == "__main__": + main()