Run python3 with no filename and you land in the REPL - an
interactive prompt where you type one line of Python and see the
result straight away. REPL stands for Read, Evaluate, Print, Loop.
It reads what you type, runs it, prints the result, and waits for the
next line.
Type python3 and press Enter. The prompt changes to >>>, which
means Python is waiting for you:
$ python3
Python 3.12.3
>>> 2 + 2
4
>>> "web-01".upper()
'WEB-01'
>>>
Notice you did not have to print anything. In the REPL, the value of
whatever you type is echoed back automatically. To leave, type
exit() and press Enter, or press Ctrl and D together.
The REPL is a scratchpad. It shines when you want a quick answer without writing a file:
Reach for it whenever you catch yourself wondering "what would this line actually do".
In the REPL, a single underscore holds the value of the last expression. It saves retyping:
>>> 1024 * 8
8192
>>> _ / 1000
8.192
Anything you type in the REPL is gone once you close it. There is no file to save, re-run, or hand to a teammate. The moment you want to keep code and run it again, put it in a script file, which is the next node.