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

Lesson 01

What is a Program?

Learn what a Python program is, why we write one, and why files use the .py extension.

Beginner10 min

What you will learn

By the end of this lesson, you'll understand:

  • What is a program?
  • What does optimization mean?
  • Why do Python files use the .py extension?
  • What is the purpose of writing a program?
Developer writing a Python programDeveloper writing a Python program

What is a Program?

A set of optimized instructions is called a program.

A program contains a sequence of instructions written by a programmer to perform a specific task.

Visual idea

Program flow: Input, Process, Output

A real Python program follows this simple flow:

  1. Receive input
  2. Process the instructions
  3. Produce output

What does "Optimized" mean?

According to your notes, optimization means either maximum or minimum.

In programming, we try to write instructions that use:

Goal Meaning
Less Time Complexity Executes faster
Less Space Complexity Uses less memory

Example

A faster solution is considered more optimized because it reduces execution time.

Why do Python files use .py?

Every Python program is saved with the .py extension.

hello.py file

.py indicates that the file contains a Python program.

You write your instructions inside this file, save it, and Python executes those instructions.

text
FileName.py

Purpose of Writing a Program

The purpose of a program is simple:

To perform an operation, task, or activity.

Everyday examples

App Task
Calculator Add, subtract, multiply
Email app Send and receive messages
Navigation Find the shortest route
Property app Search and post listings

Each of these is simply a collection of instructions designed to complete a specific job.

How a Python Program Looks

A minimal Python program:

python
print("Hello, World!")

What happens?

  • print() is an instruction
  • Python executes it
  • The output appears on the screen

Interactive vs Batch Mode

Your notes introduce two approaches to developing Python programs.

Interactive vs Batch Mode
Interactive Mode Batch Mode
Write one statement at a time and see the result immediately Write the program in a .py file, save it, then execute it
Best for learning and testing Used for real applications

We'll study these in the next lessons.

Key Terms

Term Definition
Program A set of optimized instructions
Instruction A command executed by Python
Optimization Reducing time or memory usage
.py Python program file extension
Task The operation the program performs

Summary

  • A program is a set of optimized instructions
  • Optimization focuses on less execution time and less memory usage
  • Python programs are saved as FileName.py
  • The purpose of a program is to perform a task or activity
  • The next lesson covers Interactive Mode vs Batch Mode

Quick knowledge check

  1. What is a program?
    A set of optimized instructions.

  2. What does .py represent?
    A Python program file.

  3. What are the two optimization goals mentioned in your notes?
    Less time complexity and less space complexity.

  4. Which approach is commonly used for real applications?
    Batch Mode.