Skip to main content
MahiDev — Learn. Build. Become AI-ready.

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.

Beginner15 min

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:

text
addex3.py

Related 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

Write code, save as .py, run program, get output

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 Python projectPyCharm Python project

PyCharm — professional Python IDE

VS Code PythonVS Code Python

VS Code — widely used editor

Jupyter NotebookJupyter Notebook

Jupyter Notebook (Anaconda) — data science and AI

Spyder IDESpyder IDE

Spyder (Anaconda) — scientific Python development

Google ColabGoogle Colab

Google Colab — cloud-based Python notebook

Sublime TextSublime Text

Sublime Text — lightweight code editor

Your notes also mention Python IDLE as a tool that can create and save .py files.

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:

python
# 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

text
python addex3.py

Method 2

text
py addex3.py

Both python and py are tools used to execute a Python program from the Windows Command Prompt.

Example execution

text
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:

text
E:\KVR-PYTHON-4PM\BATCH MODE> py addex3.py

The 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?

addex3.py: run, enter 3 and 6.7, sum 9.7

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

  1. Create a project in an IDE (VS Code, PyCharm, and so on)
  2. Write code inside .py files (addex1.py, addex2.py, addex3.py)
  3. Save the program
  4. Run it with python addex3.py or the IDE Run button
  5. 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 .py file
  • 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.py or py addex3.py
  • Batch Mode produces reusable, maintainable Python programs

Quick knowledge check

  1. What file is used for the dynamic add program in this module?
    addex3.py

  2. Which approach is used for real-time applications?
    Batch Mode

  3. Name two commands that execute that file.
    python addex3.py and py addex3.py

  4. What is the main advantage of Batch Mode over Interactive Mode?
    The program is saved and reusable.

Next lesson: print() — displaying output in Python.