Python calculator
In, the previous blog we have learnt how to make a simple calculator in python. So, in this blog we will be learning how to make a type of a complex calculator.
1 min readJul 3, 2020
So, let us start with calculator.
The reason behind why I am saying that this is a type of a complex calculator because in this we have to define some operators
Step — 1 so, as the previous calculator we will be taking the input for the first number
num1=float(input('Enter the first number in your basic equation: '))
Step — 2 We have to take the input form the user to tell us the operator i.e. what the user want to do like addition, subtraction e.t.c.
op = input('Select the operator(+,-,*,/,**,//)')
Step — 3 As the step one we have to take the input from the user to give us the input for the second number.
num2=float(input('Enter the second number in your basic equation: '))
Step — 4 Now, we have to define some operators
if op == "+":
print(num1+num2)
elif op == "-":
print(num1-num2)
elif op == "*":
print(num1*num2)
elif op == "/":
print(num1+num2)
elif op == "**":
print(num1**num2)
elif op == "//":
print(num1//num2)
else:
print('Please enter a real operator')
So, that’s all for today’s blog.
The open source code of the calculator