# Python Program to Make a Simple Calculator

In this example, we will learn to make a simple calculator using the functions. To better understand this example, make sure you have knowledge of the following tutorials:-

## Python Program to Make a Simple Calculator

def add(x, y):
return x + y

def subtract(x, y):
return x - y

def multiply(x, y):
return x * y

def divide(x, y):
return x / y

while True:
print("#### CALCULATOR ####")
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))

print("Select operation.")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")

choice = input("Enter choice(1/2/3/4):")
result = 0

if choice == '1':
elif choice == '2':
result = subtract(num1, num2)
elif choice == '3':
result = multiply(num1, num2)
elif choice == '4':
result = divide(num1, num2)
else:
print("Invalid Input")

print("Result = ", result)

quit = input("Do you want to continue (y/n) ?")
if quit == 'n':
break


The output of the above program is:-

#### CALCULATOR ####
Enter first number: 5
Enter second number: 3
Select operation.