This is a simple calculator using the python programming language. The program provide a menu to the user to choose the type of operation they want to perform, after which the program will ask for 2 number to calculate. The program will run infinitely until the user quit the program.
isRunning = True
while isRunning:
print("\n1 = Addition")
print("2 = Subtraction")
print("3 = Multiplication")
print("4 = Division")
print("5 = Exit program")
cmd = int(input("Enter number : "))
if cmd == 1:
print("Addition")
first = int(input("Enter first number :"))
second = int(input("Enter second number :"))
result = first + second
print(str(first) +'+' +str(second) +'=' + str(result))
elif cmd == 2:
print("Subtraction")
first = int(input("Enter first number :"))
second = int(input("Enter second number :"))
result = first - second
print(str(first) +"-" +str(second) +"=" + str(result))
elif cmd == 3:
print("Multiplication")
first = int(input("Enter first number :"))
second = int(input("Enter second number :"))
result = first * second
print(str(first) + "*" +str(second) +"=" + str(result))
elif cmd == 4:
print("Division")
first = int(input("Enter first number :"))
second = int(input("Enter second number :"))
result = first / second
print(str(first) +"/" +str(second) +"=" + str(result))
elif cmd == 5:
print("Quit!")
isRunning = False