Lesson 01
What is a Program?
Learn what a Python program is, why we write one, and why files use the .py extension.
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
.pyextension? - What is the purpose of writing a 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
A real Python program follows this simple flow:
- Receive input
- Process the instructions
- 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.
.py indicates that the file contains a Python program.
You write your instructions inside this file, save it, and Python executes those instructions.
FileName.pyPurpose 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:
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 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
-
What is a program?
A set of optimized instructions. -
What does
.pyrepresent?
A Python program file. -
What are the two optimization goals mentioned in your notes?
Less time complexity and less space complexity. -
Which approach is commonly used for real applications?
Batch Mode.