Introduction
From the Python Programming Basics curriculum
TL;DR
Python is a popular, easy-to-read programming language that lets you tell computers what to do using simple instructions. You'll write code in a text file, and a special program called an "interpreter" will translate it for the computer to understand and run. Getting started involves installing Python and learning basic commands to see your code in action.
1. The Mental Model
Think of Python as a set of instructions you write down for a very obedient but not-so-smart assistant (your computer). You type these instructions (your code) in a language the assistant understands, and it performs tasks exactly as you've described.
2. The Core Material
Python is a high-level, general-purpose programming language. "High-level" means it's designed to be readable by humans, making it easier to learn and use than "low-level" languages closer to the computer's raw machine code. "General-purpose" means you can use it for many different things, like web development, data analysis, artificial intelligence, and automation.
How Python Code Runs

Photo by Nemuel Sereti on Pexels
When you write Python code, you save it in a file, typically ending with .py (e.g., my_program.py). To run this file, you use a program called the Python interpreter. The interpreter reads your code line by line, translates it into instructions the computer can execute, and then runs those instructions.
Here’s a simple flow:
graph TD
A["You write Python code (.py file)"] --> B["Python Interpreter reads code"]
B --> C["Interpreter translates code"]
C --> D["Computer executes instructions"]
D --> E["Program runs (e.g., shows output)"]
Getting Python Ready

Photo by Christina Morillo on Pexels
Before you can run any Python code, you need to install the Python interpreter on your computer. You can download it from the official Python website (python.org). Most installations include pip, Python's package installer, which you'll use later to add extra tools and libraries.
Your First Python Command: print()

Photo by Rob Gee on Pexels
The print() function is one of the first things you'll learn. It simply displays whatever you tell it to in your console or terminal. It's super useful for seeing output from your programs and understanding what's going on.
# This is a comment. Python ignores lines starting with #.
# Use comments to explain your code!
print("Hello, Python world!") # This will display the text in the quotes.
print(123) # This will display the number 123.
print("My favorite number is", 7) # You can print multiple things, separated by commas.
When you run this code, it will print:
Hello, Python world!
123
My favorite number is 7
Variables: Storing Information

Photo by Daniil Komov on Pexels
In Python, you can store pieces of information in something called a variable. Think of a variable as a labeled box where you can put data. You give the box a name, and then you can put values inside it. You can also change the value later.
# Assigning a value to a variable
message = "Welcome to Python!"
lucky_number = 13
# Using variables in print()
print(message)
print("Your lucky number is:", lucky_number)
# Changing a variable's value
lucky_number = 7
print("My NEW lucky number is:", lucky_number)
3. Worked Example
Let's put print() and variables together to create a tiny interactive program.
- Open a text editor (like Notepad, VS Code, Sublime Text, or any plain text editor).
-
Type the following code:
```python
my_first_program.py
This program greets the user and tells them their favorite color.
name = "Alice"
favorite_color = "blue"print("Hello,", name + "!")
print("Your favorite color is:", favorite_color)Let's change the name and color
name = "Bob"
favorite_color = "green"print("Now, hello to", name + "!")
print("And your favorite color is now:", favorite_color)
`` 3. **Save the file** asmy_first_program.py(make sure it ends with.py). 4. **Open your command prompt or terminal.** 5. **Navigate to the directory** where you saved your file (e.g.,cd Documents\PythonPrograms). 6. **Run the program** by typingpython my_first_program.py` and pressing Enter.
You should see this output:
Hello, Alice!
Your favorite color is: blue
Now, hello to Bob!
And your favorite color is now: green
4. Key Takeaways
- Python is a human-readable language for giving instructions to computers.
- The Python interpreter translates your
.pycode files for the computer to run. - You need to install Python on your machine to start coding.
- The
print()function is essential for displaying output and debugging. - Variables are like labeled boxes used to store and manage data in your programs.
- Comments (lines starting with
#) help explain your code and are ignored by Python.
Common Mistakes:
- Forgetting to save your file with the .py extension.
- Typing Print() instead of print() (Python is case-sensitive!).
- Not putting text in quotes when using print() (e.g., print(Hello) will cause an error).
- Misspelling variable names after you've defined them.
5. Now Try It
Spend 15 minutes:
1. Install Python on your computer if you haven't already.
2. Create a new file called my_greetings.py.
3. Write code that uses at least two different variables (e.g., city and temperature).
4. Use print() statements to display a greeting that includes the values from your variables.
5. Run your my_greetings.py file from your terminal.
Success looks like: Seeing your custom greeting printed in the terminal with the correct values from your variables. For example: "Welcome to London! The temperature is 20 degrees Celsius."
Frequently asked about Introduction
Study this next
Get the full Python Programming Basics curriculum
Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.
Save this course free