لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

## Lesson 18: Build Your Own Python Calculator

Code

first = input("enter your first number : ")

operator = input("enter operator(+,-,*,/,%,**) : ")

second = input("enter your second number : ")

first = int(first)

second = int(second)

if operator == "+":

print( first + second)

elif operator == "-":

print( first - second)

elif operator == "*":

print( first * second)

elif operator == "/":

print( first / second)

elif operator == "%":

print( first % second)

elif operator == "**":

print(first ** second)

else :

print("invalid operation")

Learn how to create a simple calculator?

Using Python coding that can add, subtract, multiply or divide depending upon the input from the user.

User choose the desired operation.

Options 1, 2, 3, 4, 5, 6 are valid.

If user chooses any operator other than the above six valid operators it is shown as("invalid operation").

Two numbers are taken if…elif…else branching is used to execute a particular section.