Lesson 1: Introduction to Python and Setup
Lesson 1: Introduction to Python and Setup
Many big companies, like Google and YouTube, use Python. It is also used in science, space exploration, and even creating special effects in films!
In this lesson, we will:
✅ Learn what Python is and why it’s useful.
✅ Install Python on your computer.
✅ Install a code editor (Thonny or VS Code) to write Python programs.
✅ Write your first simple program in Python.
Step 1: Installing Python
To start coding, we need to install Python on your computer.
- Open your web browser (Chrome, Edge, Firefox, or Safari).
- Go to https://www.python.org/downloads/.
- Click the big yellow button that says Download Python (it will choose the best version for your computer).
- When the file finishes downloading, open it.
- A window will pop up—make sure you tick the box that says “Add Python to PATH” before clicking Install Now.
- Wait for the installation to finish, then click Close.
✔ Python is now installed!
Step 2: Installing a Code Editor
A code editor is a special program that helps you write and run Python code.
Option 1: Thonny (Recommended for Beginners)
Thonny is a simple editor designed for beginners.
- Go to https://thonny.org/.
- Click the Download button and install it like any other program.
- Open Thonny—this is where you will write your Python programs!
Option 2: Visual Studio Code (For Older Students)
If you want a more advanced editor:
- Go to https://code.visualstudio.com/.
- Click Download and install it.
- Open VS Code, then install the Python extension (it will ask you to do this when you open a Python file).
Step 3: Writing Your First Python Program
Now that we have Python and a code editor, let’s write our first program!
- Open Thonny (or VS Code).
- In the new window, type this code exactly:
print("Hello, World!") - Click the Run button (it looks like a green play button).
- You should see the words Hello, World! appear on the screen.
🎉 Congratulations! You just wrote your first Python program!
How Does This Work?
print()is a command that tells Python to display something on the screen.- The words inside the brackets (
"Hello, World!") are called a string (text in quotation marks). - Every instruction in Python follows a syntax (rules for writing code).
Step 4: Adding Comments to Your Code
A comment is a line in your program that helps explain what the code does. Python ignores comments, so they don’t affect the program.
Try adding a comment to your code:
# This program prints a message to the screen
print("Hello, World!")In Python, anything after # is a comment. It helps people (including you!) understand what the code is doing.
To be a good programmer you do not need to add comments, but to be a great coder, always comment your code, so that other coders know what you are trying to do.
Challenge: Personalised Greeting
Let’s make the program more fun by printing your name!
- Change the code so it says hello to you.
print("Hello, Alex!") - Replace Alex with your own name and run the program again.
Summary of This Lesson
✅ Python is a powerful and easy-to-learn programming language.
✅ We installed Python and a code editor (Thonny or VS Code).
✅ We wrote our first program using print().
✅ We learned about comments (#) and why they are useful.
Next Lesson: Variables and Data Types
In the next lesson, we will learn how to store information in a Python program using variables! 🎯
