# Python simple calculator program

In this tutorial, you will learn about about simple calculator program. you can do add, subtract, multiplication and division.

Code:

` ` ``` # Python simple calculator program # Function to add two numbers def add(digit1, digit2): return digit1 + digit2 # Function to subtract two numbers def subtract(digit1, digit2): return digit1 - digit2 # Function to multiply two numbers def multiply(digit1, digit2): return digit1 * digit2 # Function to divide two numbers def divide(digit1, digit2): return digit1 / digit2 print("Please select operation -\n" "1. Add\n" "2. Subtract\n" "3. Multiply\n" "4. Divide\n") # Take input from the user select = input("Select One number for calulator operation form 1, 2, 3, 4 :") digit1 = int(input("Enter first number: ")) digit2 = int(input("Enter second number: ")) if select == '1': print(digit1, "+", digit2, "=", add(digit1, digit2)) elif select == '2': print(digit1, "-", digit2, "=", subtract(digit1, digit2)) elif select == '3': print(digit1, "*", digit2, "=", multiply(digit1, digit2)) elif select == '4': print(digit1, "/", digit2, "=", divide(digit1, digit2)) else: print("Invalid input") ``` ` ` ` `

Output:

2. Subtract
3. Multiply
4. Divide

Select One number for calulator operation form 1, 2, 3, 4 :1

Enter first number: 5

Enter second number: 6
5 + 6 = 11

2. Subtract
3. Multiply
4. Divide

Select One number for calulator operation form 1, 2, 3, 4 :2

Enter first number: 10

Enter second number: 5
10 – 5 = 5

2. Subtract
3. Multiply
4. Divide

Select One number for calulator operation form 1, 2, 3, 4 :3

Enter first number: 3

Enter second number: 3
3 * 3 = 9

2. Subtract
3. Multiply
4. Divide

Select One number for calulator operation form 1, 2, 3, 4 :4

Enter first number: 10

Enter second number: 2
10 / 2 = 5.0