I’m a beginner and I try to code a calculator.
When I turn it into an executable I write number 1 and the operator and number 2 and it exits form the program and dot get me the answer
in visual it get me the answer.
This is the code
Thx for help
num1 = int(input('enter first num: '))
op = input('enter your op: ')
num2 = int(input('enter second num: '))
if op == '+':
print(num1 + num2 )
elif op == '-':
print(num1 - num2 )
elif op == '*':
print(num1 * num2 )
elif op == '/':
print(num1 / num2 )
>Solution :
It exits because it reaches the end of code. Try either asking for input to quit or sleeping at the end
num1 = int(input('enter first num: '))
op = input('enter your op: ')
num2 = int(input('enter second num: '))
if op == '+':
print(num1 + num2 )
elif op == '-':
print(num1 - num2 )
elif op == '*':
print(num1 * num2 )
elif op == '/':
print(num1 / num2 )
input("Press ENTER to quit.")