Interactive prompt
The interactive prompt is the easiest way to run your Python programs – simply type the code in this command-line interface. To start the interactive prompt, type python from the Windows command prompt or Linux shell and press Enter:
After you start the interactive prompt, the information about the Python version along with some useful information about the operating system will be displayed. Below these information is the >>> prompt, which indicates that you’re in an interactive Python interpreter session. The code you enter after the prompt will be executed once you press Enter. For example, to print the text Hello world, you can use the print function:
C:Python34>python Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In tel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print ('Hello world!') Hello world!
In the example above you can see that the result of the print function was echoed back right away (Hello world!). However, the code you enter in the interactive prompt will not be saved in a file. This is why this prompt is not usually used to very often; it is usually used only for testing or experimental purposes.
You can type multiple Python commands and they will be run immediately after they are entered:
C:Python34>python Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print ('Hello world!') Hello world! >>> x=5 >>> print (x) 5 >>>
To exit the interactive prompt, press Ctrl+Z on Windows or Ctrl+D on Linux.