Sunday, October 25, 2020

REPL in Python

Python command Line Environment is known as Read Eval Print Loop or REPL. Python reads the text typed in command line, evaluates it, prints the result and loops back to the beginning.

On start python REPL displays version information of python that is running on the  machine and prompts a triple arrow >>> waiting for input at the REPL.
Basic arithmetic operation at the REPL nine plus ten is nineteen and sixtyFive times five is three hundred twenty five.
In above image python read the input, evaluated it, printed result to the console and looped back again and waiting for input.
At the prompt type print("Python Hacker") and press Enter, python immediately evaluates and prints the value at the prompt. Here the result is due to print function.
At the python prompt type special symbol underscore _ and you can see magic happens here. python prints the same previously printed value, works only on REPL
To exit from REPL on windows platforms use Ctrl + Z followed by Enter. On Mac or Linux systems use Ctrl + D.

No comments:

Post a Comment

Operations on Python Dictionaries