liveBook · Manning

Python interactive prompt

As explained in Learn AI-Assisted Python Programming, Second Edition

The Python interactive prompt is the interpreter interface marker at which users enter Python code for immediate evaluation.

The Python interactive prompt is the interpreter interface marked by >>>, where you enter Python code and immediately see its result. Python reads, executes, and prints each entry in a repeating REPL loop. section 4.3 section 3.3.1

Use the prompt to:

  • Experiment with expressions, such as >>> 5 * 4, and observe the response. section 4.3
  • Call a defined function repeatedly without adding temporary calls to the program. section 3.3.1
  • Run quick tests, then revise the code when an output is wrong; rerun earlier tests after making changes. section 6.3.1
  • Enter multi-line structures such as conditionals: >>> starts a new statement, while ... indicates unfinished input. section 4.3.3

Testing a function

After defining money_made, enter >>> money_made(10, 15, 17) to receive 20. Try a loss with >>> money_made(10, 17, 15), which returns -20, or equal prices, which returns 0. section 3.3.1

Figure 3.3 Running Python in an interactive session in VS Code. Note the >>> at the bottom of the TERMINAL tab.
figure

A VS Code terminal figure shows the >>> marker in a running interactive Python session. section 3.3.1

How Learn AI-Assisted Python Programming, Second Edition covers it

How deep it goes
Explains the REPL cycle, prompt markers, and practical testing, but stops short of interpreter implementation details.
Examples
Demonstrates arithmetic, stock-profit calculations, longest-word testing, and conditional age examples.
What it assumes
Assumes basic Python code entry and function definitions while teaching prompt markers and interactive execution from simple examples.
What you can do after
Apply it via a Python prompt to run expressions, call functions, inspect results, and perform quick tests.
How it connects
Connects interactive experimentation with REPLs, functions, conditionals, and software testing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn AI-Assisted Python Programming, Second Edition. The section links point to the parts of the book it draws on.