From cd288cc53634697f2a0e8e25e1004be82d5010c9 Mon Sep 17 00:00:00 2001 From: sumit120398 <72256303+sumit120398@users.noreply.github.com> Date: Sat, 3 Oct 2020 00:34:34 +0530 Subject: [PATCH] Calculator Python Program to Make a Simple Calculator --- Python Program to Make a Simple Calculator | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Python Program to Make a Simple Calculator diff --git a/Python Program to Make a Simple Calculator b/Python Program to Make a Simple Calculator new file mode 100644 index 0000000..72ac9c2 --- /dev/null +++ b/Python Program to Make a Simple Calculator @@ -0,0 +1,71 @@ +def add(x, y): + + """This function adds two numbers"" + + return x + y + +def subtract(x, y): + + """This function subtracts two numbers""" + + return x - y + +def multiply(x, y): + + """This function multiplies two numbers""" + + return x * y + +def divide(x, y): + + """This function divides two numbers""" + + return x / y + + + +print("Select operation.") + +print("1.Add") + +print("2.Subtract") + +print("3.Multiply") + +print("4.Divide") + + + +choice = input("Enter choice(1/2/3/4):") + + + +num1 = int(input("Enter first number: ")) + +num2 = int(input("Enter second number: ")) + + + +if choice == '1': + + print(num1,"+",num2,"=", add(num1,num2)) + + + +elif choice == '2': + + print(num1,"-",num2,"=", subtract(num1,num2)) + + + +elif choice == '3': + + print(num1,"*",num2,"=", multiply(num1,num2)) + +elif choice == '4': + + print(num1,"/",num2,"=", divide(num1,num2)) + +else: + + print("Invalid input")