11-15-2025, 10:15 PM
Chapter 3 — Your First Python Program
Where you officially become a programmer
In this chapter, you will:
• write your first real Python program
• run it
• understand exactly what the computer is doing
• learn the rules of Python’s “grammar”
This is where everything begins.
---
3.1 Creating Your First Python File
Open VS Code.
1. Click File → New File
2. Save it immediately as:
hello.py
(Every Python file ends with .py)
Your editor is now ready for code.
---
3.2 The First Line Every Beginner Writes
Type this:
This is the traditional first program across the entire world.
Now run it:
VS Code:
• Press the “Run Python File” button
OR
Terminal:
You should see:
Hello, world!
You have now written a real, valid Python program.
---
3.3 How the Program Works (Explained Simply)
Python reads your file from top to bottom.
The print command tells the computer:
“Display whatever is inside the brackets.”
Like this:
Anything inside quotation marks is text (called a string).
---
3.4 Python Grammar — Very Simple Rules
Python has a very clean language structure.
Here are the essential rules you need right now:
Rule 1: Every instruction goes on its own line.
Rule 2: Text must be inside quotation marks.
Rule 3: Python is case-sensitive.
“print” is correct
“Print”, “PRINT”, and “pRint” will NOT work.
Rule 4: Brackets must be matched.
---
3.5 Adding More Lines
Try this:
When you run it, Python prints each line in order.
This is the basic structure of every program:
a list of instructions, executed top to bottom.
---
3.6 Adding Comments (Notes to Yourself)
A comment is a line the computer ignores.
It starts with a # symbol.
Programmers use comments to explain what their code does.
You will use comments in your exercises and projects.
---
3.7 Exercise — Write a Mini Program
Create a file called intro.py
Write a program that displays:
• your name
• your favourite number
• your favourite hobby
• a positive message
Example structure:
Run the file to see your results.
(This exercise builds confidence and helps you understand the basics.)
---
3.8 Small Challenge
Try writing a program that prints:
1. A sentence on one line
2. A second sentence
3. A blank line
4. Two more sentences
Hint: A blank line is just:
---
3.9 Chapter Summary
• You created your first Python file
• You wrote your first real program
• You learned how print() works
• You learned Python’s simple rules
• You learned what comments are
• You wrote your first mini project
Next, we level up to:
Chapter 4 — Variables & Data Types
This is where you start storing information and building real logic.
---
Written and Compiled by Lee Johnston — Founder of The Lumin Archive
Where you officially become a programmer
In this chapter, you will:
• write your first real Python program
• run it
• understand exactly what the computer is doing
• learn the rules of Python’s “grammar”
This is where everything begins.
---
3.1 Creating Your First Python File
Open VS Code.
1. Click File → New File
2. Save it immediately as:
hello.py
(Every Python file ends with .py)
Your editor is now ready for code.
---
3.2 The First Line Every Beginner Writes
Type this:
Code:
print("Hello, world!")This is the traditional first program across the entire world.
Now run it:
VS Code:
• Press the “Run Python File” button
OR
Terminal:
Code:
python hello.pyYou should see:
Hello, world!
You have now written a real, valid Python program.
---
3.3 How the Program Works (Explained Simply)
Python reads your file from top to bottom.
The print command tells the computer:
“Display whatever is inside the brackets.”
Like this:
Code:
print("Hello!") # prints Hello!Anything inside quotation marks is text (called a string).
---
3.4 Python Grammar — Very Simple Rules
Python has a very clean language structure.
Here are the essential rules you need right now:
Rule 1: Every instruction goes on its own line.
Code:
print("A")
print("B")Rule 2: Text must be inside quotation marks.
Code:
print("This is text")Rule 3: Python is case-sensitive.
“print” is correct
“Print”, “PRINT”, and “pRint” will NOT work.
Rule 4: Brackets must be matched.
Code:
print("Hello") # correctCode:
print("Hello" # error---
3.5 Adding More Lines
Try this:
Code:
print("This is my first program.")
print("I am learning Python.")
print("It feels easy!")When you run it, Python prints each line in order.
This is the basic structure of every program:
a list of instructions, executed top to bottom.
---
3.6 Adding Comments (Notes to Yourself)
A comment is a line the computer ignores.
It starts with a # symbol.
Code:
# This is a comment
print("This will run")
# This won't run: print("Secret code")Programmers use comments to explain what their code does.
You will use comments in your exercises and projects.
---
3.7 Exercise — Write a Mini Program
Create a file called intro.py
Write a program that displays:
• your name
• your favourite number
• your favourite hobby
• a positive message
Example structure:
Code:
print("My name is ...")
print("My favourite number is ...")
print("I enjoy ...")
print("Today is a great day!")Run the file to see your results.
(This exercise builds confidence and helps you understand the basics.)
---
3.8 Small Challenge
Try writing a program that prints:
1. A sentence on one line
2. A second sentence
3. A blank line
4. Two more sentences
Hint: A blank line is just:
Code:
print("")---
3.9 Chapter Summary
• You created your first Python file
• You wrote your first real program
• You learned how print() works
• You learned Python’s simple rules
• You learned what comments are
• You wrote your first mini project
Next, we level up to:
Chapter 4 — Variables & Data Types
This is where you start storing information and building real logic.
---
Written and Compiled by Lee Johnston — Founder of The Lumin Archive
