As I said in the previous section, after installing Python, after entering "python" on the command line, if successful, you will get a window similar to the following:
As you can see, there are 3 > symbols (>>>) at the end. >>> is called the python command prompt (prompt), when Python waits for you to enter the code. You can now enter a line of Python code, and Python executes that code. This mode is called Python interactive mode (interactive mode), because Python waits for you to enter the code and execute it.
For example, you can enter an expression for Python to calculate. For example, to calculate the "a", you can enter a "+" at the command prompt, and then press ENTER:
>>> 1 + 1
When you press ENTER, Python outputs the results, which is 2.
To exit Python interaction mode, you can enter exit () at the python command prompt:
>>> exit ()
You can also enter quit ():
>>> quit ()
You can also enter an EOF (end of file) character, on Windows Ctrl+z,linux is ctrl+d.
In the future code, if a line that begins with >>> is present, it means that the line of code is entered in Python interactive mode.
There is a difference between entering code and running a. py file in Python interactive mode. On the python command line, Python will wait for you to enter the code one line at a time, but you don't have the opportunity to run the. py file, and you'll normally run out of a. py file immediately (so you can't see what the program is outputting).
There are more details about the Python interaction pattern, which will be discussed later.
Python Tutorial (1.2)--python Interactive mode