From fd79463f23798a925f373706262f9c7ab6fa698d Mon Sep 17 00:00:00 2001 From: Midhun Mohanan <60269061+TheGr4yhAt@users.noreply.github.com> Date: Fri, 2 Oct 2020 17:30:32 +0530 Subject: [PATCH] Create PythCalc --- PythCalc | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 PythCalc diff --git a/PythCalc b/PythCalc new file mode 100644 index 0000000..5a93154 --- /dev/null +++ b/PythCalc @@ -0,0 +1,88 @@ + +# Function to add two numbers + +def add(num1, num2): + + return num1 + num2 + + +# Function to subtract two numbers + +def subtract(num1, num2): + + return num1 - num2 + + +# Function to multiply two numbers + +def multiply(num1, num2): + + return num1 * num2 + + +# Function to divide two numbers + +def divide(num1, num2): + + return num1 / num2 + + + +print("Please select operation -\n" \ + + "1. Add\n" \ + + "2. Subtract\n" \ + + "3. Multiply\n" \ + + "4. Divide\n") + + + + +# Take input from the user + +select = int(input("Select operations form 1, 2, 3, 4 :")) + + + +number_1 = int(input("Enter first number: ")) + +number_2 = int(input("Enter second number: ")) + + + +if select == 1: + + print(number_1, "+", number_2, "=", + + add(number_1, number_2)) + + + +elif select == 2: + + print(number_1, "-", number_2, "=", + + subtract(number_1, number_2)) + + + +elif select == 3: + + print(number_1, "*", number_2, "=", + + multiply(number_1, number_2)) + + + +elif select == 4: + + print(number_1, "/", number_2, "=", + + divide(number_1, number_2)) + +else: + + print("Invalid input")