diff --git a/Calculator/Calculator.py b/Calculator/Calculator.py new file mode 100644 index 0000000..fb5a646 --- /dev/null +++ b/Calculator/Calculator.py @@ -0,0 +1,31 @@ +# This function performs additiion +def add(a, b): + return a + b +# This function performs subtraction +def subtract(a, b): + return a - b +# This function performs multiplication +def multiply(a, b): + return a * b +# This function performs division +def divide(a, b): +return a / b +print("Select an operation.") +print("+") +print("-") +print("*") +print("/") +# User input +choice = input("Enter operator to use:") +A = int(input("Enter first number: ")) +B = int(input("Enter second number: ")) +if choice == '+': + print(A,"+",B,"=", add(A,B)) +elif choice == '-': + print(A,"-",B,"=", subtract(A,B)) +elif choice == '*': + print(A,"*",B,"=", multiply(A,B)) +elif choice == '/': + print(A,"/",B,"=", divide(A,B)) +else: +print("Invalid input") diff --git a/Calculator/ReadMe.md b/Calculator/ReadMe.md new file mode 100644 index 0000000..63fdfda --- /dev/null +++ b/Calculator/ReadMe.md @@ -0,0 +1,13 @@ +# Basic Calculator + +## I Have made this Calculator by Python + +### First of all i take the input of operator (+,-,*,/) + +### Then we take inout of bot operand + +### Then the value goes to function as per the operand entered + + ![Screenshot (45)](https://user-images.githubusercontent.com/78155393/193403781-2ca655e7-1ddf-4e9e-ad0c-e344fd4899dd.png) + +## Hence the result is printed