The REPL is an interactive Python session: Read, Evaluate, Print, Loop. It is an easy place to test small language ideas.
Understanding the Concept
Start the Python interpreter without a script name. It displays its version information and a prompt. Type an expression and press Enter to evaluate it. Python prints the result when the expression produces a value. You can also assign names and use them on later lines. Exit with exit() or the supported keyboard shortcut. The interactive session does not automatically save your history as a reusable Python file.
When and Why You Would Use This
Use the REPL for short experiments, not as your only project workspace. When an example grows beyond a few lines, move it into a saved .py file in PyCharm so that you can rerun it consistently.
Practical Example
>>> first_amount = 14
>>> second_amount = 6
>>> first_amount + second_amount
20
>>> exit()
Understanding the Example
The third command evaluates to 20. Assignment statements themselves do not print a value. The >>> prefix is shown to make the transcript recognizable; do not type the prefix characters.
Try It Yourself
Open Python interactively, calculate two values, exit, and reopen. Observe that an earlier variable is no longer defined.
Common Beginner Mistakes
- Typing Python statements into the operating-system shell without starting the interpreter first.
- Copying >>> prompt characters into a program.
- Mistaking interactive variables for persistent values after the interpreter exits.
Key Takeaways
- REPL lets you evaluate expressions one at a time.
- Assignments persist only for the current interactive session.
- Use scripts for larger, repeatable exercises.