From 0dab46d30c05eb5702998858e918f835735a554b Mon Sep 17 00:00:00 2001 From: Ilyas Shaikh <72152969+ilyas829@users.noreply.github.com> Date: Thu, 3 Oct 2024 16:02:21 +0000 Subject: [PATCH] Added Calculator code in python --- Add Code Here/calculator.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Add Code Here/calculator.py diff --git a/Add Code Here/calculator.py b/Add Code Here/calculator.py new file mode 100644 index 00000000000..9167ceeafe9 --- /dev/null +++ b/Add Code Here/calculator.py @@ -0,0 +1,32 @@ +def add(a,b): + return (a+b) +def sub(a,b): + return (a-b) +def mult(a,b): + return (a*b) +def div(a,b): + return (a//b) + + +print("1. Addition") +print("2 . Subtraction") +print("3. Multiplication") +print("4. Division") + + +while True: + choice = int(input("Enter Choice ")) + if choice == 1 or choice ==2 or choice ==3 or choice ==4 or choice ==5: + a= int(input("Enter 1st number")) + b= int(input("Enter 2nd number")) + if choice == 1: + print(add(a,b)) + elif choice == 2: + print(sub(a,b)) + elif choice == 3: + print(mult(a,b)) + elif choice == 4: + print(div(a,b)) + else: + print("Enter valid choice") + break \ No newline at end of file