Adsense Ad

Wednesday, 8 May 2019

Calculator in Python example



#Assignment Calculator
prompt = "Enter number "
num1 = int(input(prompt))
prompt = "To DO? '+','-','*','/' "
todo = input(prompt)
prompt = "Enter number again "
num2 = int(input(prompt))
if todo == '+':
    print(num1+num2)
elif todo == '-':
    print(num1-num2)
elif todo == '*':
    print(num1*num2)
elif todo == '/':
    print(num1/num2)  

Enter number 16
To DO? '+','-','*','/' -
Enter number again 8
Result: 8

No comments: