how to make a calculator in python sim0oe code example
Example 1: how to make a python calculator
import time
def add():
n1 = input('Enter a number: ')
n2 = input('Enter another number: ')
time.sleep(1)
print(int(n1)+int(n2))
def multiply():
n1 = input('Enter a number: ')
n2 = input('Enter another number: ')
time.sleep(1)
print(int(n1)*int(n2))
def divide():
n1 = input('Enter a number: ')
n2 = input('Enter another number: ')
time.sleep(1)
print(int(n1)int(n2))
def subtract():
n1 = input('Enter a number: ')
n2 = input('Enter another number: ')
time.sleep(1)
print(int(n1)-int(n2))
run = True
while run:
ans = input('Select an opreation: ')
if(ans=='Addition'):
add()
if(ans=='Divide'):
divide()
if(ans=='Multiply'):
multiply()
if(ans=='Subtract'):
subtract()
Example 2: calculator in python
qus = input('')
if(qus=='ADDITON'):
no1 = int(input())
no2 = int(input())
print(no1+no2)
if(qus=='MULTIPLICATION'):
no1 = int(input())
no2 = int(input())
print(no1*no2)
if(qus=='DIVISION'):
no1 = int(input())
no2 = int(input())
print(no1/no2)
if(qus=='SUBTRACTION'):
no1 = int(input())
no2 = int(input())
print(no1-no2)