Lesson 02
Interactive Approach
Run one Python statement at a time in the command prompt or IDLE shell — useful for testing, not for large apps.
What you will learn
By the end of this lesson, you'll understand:
- What does the Interactive Approach mean?
- Which tools use it?
- Why is it useful for testing one instruction?
- Why is it not suitable for large applications?
What is the Interactive Approach?
The Interactive Approach is a way of learning and testing Python where you execute one statement at a time and immediately receive one output at a time.
Instead of writing a complete program in a file, you type commands directly into the Python interpreter.
How it works
Key idea: One statement → One execution → One immediate result.
Where is it used?
According to your notes, the Interactive Approach is available in these tools:
| Tool | Role |
|---|---|
| Python Command Prompt | The built-in Python interpreter opened from the terminal |
| Python IDLE Shell | Python's beginner-friendly interactive environment |
The prompt usually looks like:
>>>This prompt is called the Python prompt. It indicates that Python is ready to execute your next statement.
Example
Type each line one by one.
>>> a = 10
>>> b = 20
>>> c = a + b
>>> print(a)
10
>>> print(b)
20
>>> print(c)
30What happened?
| Statement | Output |
|---|---|
a = 10 |
Variable created |
b = 20 |
Variable created |
c = a + b |
Value calculated |
print(a) |
10 |
print(b) |
20 |
print(c) |
30 |
Every statement is executed immediately.
Why is it useful?
The Interactive Approach is excellent for experimenting with Python.
| Best uses | Not suitable for |
|---|---|
Testing print() |
Large applications |
Trying input() |
Reusable projects |
| Checking formulas | Team development |
| Learning syntax | Production software |
Why can't we build real applications this way?
Your notes highlight two important limitations.
1. Instructions are not saved
When you close the Interactive Shell, your work disappears.
Unlike Batch Mode, nothing is automatically stored as FileName.py.
2. Code cannot be reused easily
A real application needs:
- Multiple files
- Functions
- Classes
- Team collaboration
- Version control
The Interactive Shell is designed for experimentation, not software development.
Interactive vs Batch Mode
| Interactive Approach | Batch Mode Approach |
|---|---|
| One statement at a time | Entire program at once |
| Immediate output | Run the saved file |
| Good for testing | Good for applications |
| Not reusable | Reusable .py program |
| Temporary session | Permanent source code |
Think of it like this:
- Interactive = calculator
- Batch Mode = complete software project
Real-world workflow
Even experienced Python developers still use Interactive Mode.
- Test a formula in the Interactive Shell
- Verify the output
- Move the working code into a
.pyfile - Build the complete application in Batch Mode
Interactive Mode helps you verify ideas quickly before writing production code.
Key Terms
| Term | Meaning |
|---|---|
| Interactive Approach | Execute one statement at a time |
| Python Prompt | >>> |
| IDLE | Python Interactive Development Environment |
| REPL | Read → Evaluate → Print → Loop |
| Temporary Session | Code is not automatically saved |
The acronym REPL is common Python terminology. Your uploaded notes describe the behavior as "one statement, one output"; REPL is the standard name for that interactive execution model.
Summary
- Interactive Approach means one statement, one output
- It is available in the Python Command Prompt and Python IDLE Shell
- The prompt is usually
>>> - It is excellent for testing and learning Python
- It is not a substitute for a saved
.pyprogram - Next lesson: Batch Mode — the industry approach
Quick knowledge check
-
What is the Interactive Approach?
Executing one Python statement at a time. -
Which symbol indicates the Python prompt?
>>> -
Is code automatically saved as a
.pyfile?
No. -
What is the primary purpose of Interactive Mode?
Testing and learning one instruction at a time.