Lesson 03
Batch Mode Approach
Save optimized instructions in a .py file such as addex3.py and run them with python addex3.py — the industry way to build apps.
What you will learn
By the end of this lesson, you'll understand:
- What does Batch Mode Approach mean?
- Why do real-time applications use Batch Mode?
- Which IDEs are commonly used?
- How do you run a Python program from the command prompt?
What is Batch Mode?
In the Batch Mode Approach, we write a set of optimized instructions, save them in a file with the .py extension, and execute the entire program.
This module’s add-two-numbers program is saved as:
addex3.pyRelated files in the same folder:
| File | Role |
|---|---|
addex1.py |
Hard-coded add |
addex2.py |
Labeled print() output |
addex3.py |
Dynamic input() add (this lesson) |
Unlike Interactive Mode, the program is saved, reusable, and can be executed whenever needed.
Batch Mode workflow
Key idea: Write once → Save → Run many times.
Why does the industry use Batch Mode?
According to your notes:
To develop any real-time application, we always go for Batch Mode.
Real applications require:
- Saved source code
- Reusable programs
- Team collaboration
- Version control
- Testing and deployment
This is why software companies build applications using .py files rather than typing commands into the Interactive Shell.
IDEs used for Batch Mode
An IDE (Integrated Development Environment) helps you write, save, debug, and run Python programs.
Common IDEs from your notes
PyCharm — professional Python IDE
VS Code — widely used editor
Jupyter Notebook (Anaconda) — data science and AI
Spyder (Anaconda) — scientific Python development
Google Colab — cloud-based Python notebook
Sublime Text — lightweight code editor
Your notes also mention Python IDLE as a tool that can create and save
.pyfiles.
How to create a Batch Mode program
Step 1 — Create a file
Save the file as addex3.py.
Step 2 — Write the program
This is the uploaded addex3.py:
# Program for adding Two Numbers
a = float(input("Enter First Value:"))
b = float(input("Enter Second Value:"))
c = a + b
print("=" * 50)
print("Val of a={}".format(a))
print("Val of b={}".format(b))
print("sum({},{})={}".format(a, b, c))
print("=" * 50)Step 3 — Save the file
The extension must be .py.
Running the program from Command Prompt
Open the terminal (Command Prompt) and go to the folder that contains addex3.py.
Method 1
python addex3.pyMethod 2
py addex3.pyBoth
pythonandpyare tools used to execute a Python program from the Windows Command Prompt.
Example execution
E:\KVR-PYTHON-6PM\BATCH MODE> python addex3.py
Enter First Value:3
Enter Second Value:6.7
==================================================
Val of a=3.0
Val of b=6.7
sum(3.0,6.7)=9.7
==================================================The same program with py:
E:\KVR-PYTHON-4PM\BATCH MODE> py addex3.pyThe output remains the same.
Classroom notes sometimes showed this run as Addopex3.py. In this zip the file is addex3.py — use that name.
What actually happens?
The program reads input, performs calculations, and displays the result.
Interactive vs Batch Mode
| Interactive | Batch Mode |
|---|---|
| One statement at a time | Set of instructions in addex3.py |
| Temporary session | Saved permanently |
| Good for testing | Good for applications |
| Hard to reuse | Reusable code |
| Immediate experimentation | Complete software development |
A practical analogy
- Interactive Mode — like using a calculator for one calculation
- Batch Mode — like writing a recipe (
addex3.py) that anyone can run repeatedly
Real-world development process
- Create a project in an IDE (VS Code, PyCharm, and so on)
- Write code inside
.pyfiles (addex1.py,addex2.py,addex3.py) - Save the program
- Run it with
python addex3.pyor the IDE Run button - Modify and reuse the same program as the project grows
This is the standard workflow for web applications, AI projects, automation scripts, and enterprise software.
Key Terms
| Term | Meaning |
|---|---|
| Batch Mode | Developing programs in saved .py files |
addex3.py |
This lesson’s add-two-numbers source file |
| IDE | Integrated Development Environment |
python |
Command used to execute a Python file |
py |
Alternative Windows launcher for Python |
Summary
- Batch Mode means writing a program in a saved
.pyfile - Real-time applications are developed using Batch Mode
- Popular IDEs include PyCharm, VS Code, Jupyter, Spyder, Colab, and Sublime Text
- Run this lesson’s program with
python addex3.pyorpy addex3.py - Batch Mode produces reusable, maintainable Python programs
Quick knowledge check
-
What file is used for the dynamic add program in this module?
addex3.py -
Which approach is used for real-time applications?
Batch Mode -
Name two commands that execute that file.
python addex3.pyandpy addex3.py -
What is the main advantage of Batch Mode over Interactive Mode?
The program is saved and reusable.
Next lesson: print() — displaying output in Python.