Python is equivalent to the system ("PAUSE")

I have encoded a basic calculator in python 3.3 and I want to be able to run it in a command window.

but as soon as I get to the end, he closes the windows before I have time to look at the final answer.

so I was wondering if there is an equivalent to the C ++ System ("PAUSE") command, to say that it does not advance further until the user is ready.

Here is my calculator code:

print('Your Very Own Basic Calculator')
first_num = int(input('Please Enter The First Number: '))
second_num = int(input('Please Enter The Second Number: '))
Equation = input('What would you like to do, multiplication, division, subtraction or     
if Equation == ('*'):
addition? *, /, -, +')
    print('The Answer is',first_num * second_num)
elif Equation == ("/"):
    print('The Answer is',first_num / second_num)
elif Equation == ('-'):
    print('The Answer is',first_num - second_num)
elif Equation == ('+'):
    print('The Answer is',first_num + second_num)

thank

+4
source share
4 answers

Use input()on p3k or raw_input()on p2.7x - it will read something from stdin, so it will wait until the user is ready.

+14
import time

time.sleep(secs)

, .

+5

win7:

import os
(...)
os.system("PAUSE")

Watch for the caps in the snippet, the pause is not PAUSE.

+1
source
import os
...
os.system("pause")

this should complete the task

-1
source

Source: https://habr.com/ru/post/1532215/


All Articles