Using Python’s Interactive Console to Run Programs

Python provides an interactive console where you can run Python code dynamically (without, for example, creating any source code files beforehand). Start Python’s interactive console by running python3 from your command line:

 $ python3
 Python 3.9.2 (default, Mar 12 2021, 18:54:15)
 [GCC 8.3.0] on linux
 Type "help", "copyright", "credits", or "license" for more information.
 >>>

After you run python3, you’ll see several lines describing the version of Python you’re running. In the preceding example, Python is on version 3.9.2. As a reminder, the examples in this book all require Python 3.7 or higher.

After running python3, your cursor will be placed just after the >>> characters. This is where ...

Get Intuitive Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.