Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Primary and secondary prompt in Python

  • Last Updated : 10 May, 2020

The ">>>" sign seen on the Python’s interactive shell is called a prompt. Python’s interactive shell, which appears after firing command “python3” (if we are working on python version 3) on the terminal, has two such prompts.

">>>" - Primary prompt
"..." - Secondary prompt

When we fire command ‘python3’ on terminal, >>> sign is immediately seen on screen. This “>>>” sign is nothing but the primary prompt.

Whenever cursor is blinking next to a primary prompt on terminal, it means interpreter will take ‘one and only one’ instruction and execute it immediately if the instruction is found valid

Example:

python3-primary-prompt

Firstly interpreter will immediately execute a = 10 while doing so it will create an integer object, store 10 inside that integer object and bind that particular object to a variable called ‘a’

After executing the first instruction, the interpreter moves to the next instruction b = 20 and immediately executes it, just like it executed a = 10, and finally prints the output.

However, once we get to see a secondary prompt that is “…”, it means that now we have entered a block, that block can be if block, else block, elif block, while, for or any other block. Once inside a block, ‘…’ signifies, all the instructions of the block, entered in front of “…” will be executed by interpreter together “as a series of instructions”.

Example:

python-secondary-prompt

Hereafter writing if statement, naturally interpreter enters in if block and starts showing “…”(secondary prompt) to indicate that now the interpreter is ready to take ‘series of instructions’, which will be executed altogether as a group if, ‘if’ statement is found valid.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!