Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python language im beginer

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading