You Already Know How to Program
What does it mean to “program” something? You might think it sounds complicated — something only tech geniuses do in dark rooms with three monitors. But here’s a secret: you already do it every single day.
Think about a recipe for making toast. You follow a set of steps in order: take a slice of bread, put it in the toaster, press the lever down, wait until it pops up, spread butter on it. If you gave those instructions to someone who had never made toast before, they could follow them and get the same result. That’s programming.
When you give someone directions to your house, write down your morning routine, or explain the rules of a game — you’re creating a program. The only difference with computer programming is that your audience is a machine, and machines need instructions to be extremely precise. A computer won’t guess what you mean. It does exactly what you tell it — nothing more, nothing less.
Programming is the art of giving a computer a precise set of instructions to solve a problem or complete a task. The language we will use to write those instructions is called Python — one of the most popular and beginner-friendly programming languages in the world.
By the end of this chapter, you will be able to:
- Write and run your first Python programs directly in the browser
- Use the
print()function to display text and numbers on screen - Understand that computers follow instructions step by step, from top to bottom
- Use Python as a calculator to perform basic arithmetic
- Combine text and numbers in your output using multiple arguments
- Recognise and fix common beginner mistakes in Python code
See It in Action
Example 1: Your First Program
Almost every programmer in history started with the same program: making the computer say “Hello, World!”. It’s a tradition that goes back to the 1970s. In Python, all it takes is a single line. Click Run Code to see it work!
print("Hello, World!")
That’s it — one line of code, and the computer does exactly what you asked. The print() function tells Python to display whatever is inside the brackets on screen. The text inside the quotation marks is called a string — it’s how we write plain text in Python.
print("I am learning Python!") or your favourite quote. Then click Run Code again to see your new message appear.
Example 2: Multiple Instructions
Programs are rarely just one line. Most of the time, you need several instructions to get something done. Python reads your code from top to bottom, running each line in order — just like reading a book. Watch what happens when we give Python three instructions:
print("Good morning!")
print("Welcome to Python.")
print("Let's write some code!")
Notice how the three messages appear in the exact order we wrote them. Python ran line 1 first, then line 2, then line 3. It will never jump ahead or skip a line on its own.
print() statement of your own at the end. Can you make the computer tell a knock-knock joke across multiple lines?
Example 3: Python as a Calculator
Python isn’t just for text — it’s brilliant at maths too. You can use it as a powerful calculator right out of the box. Notice that when we do maths, we don’t use quotation marks — we want Python to calculate the answer, not just display the symbols.
# Addition
print(2 + 3)
# Multiplication
print(10 * 5)
# Division
print(100 / 4)
# A bigger calculation
print(7 + 3 * 2)
Did you notice the last answer? 7 + 3 * 2 gives 13, not 20. That’s because Python follows the same order of operations you learnt in maths (BIDMAS/BODMAS) — multiplication happens before addition. Lines that start with # are called comments. Python ignores them completely; they’re just notes for humans reading the code.
365 * 24). What about how many minutes? Can you work out your age in days? Try using brackets to change the order of operations: compare print(7 + 3 * 2) with print((7 + 3) * 2).
Example 4: String Repetition
Here’s a fun trick — you can use the * symbol to repeat text. When you multiply a string by a number, Python repeats that text the given number of times. This is called string repetition, and it’s surprisingly useful for creating patterns and formatting your output.
# Repeat text with *
print("Ha" * 3)
# Create a divider line
print("-" * 30)
# Make a simple border
print("*" * 20)
print("* Hello, World! *")
print("*" * 20)
Notice how "Ha" * 3 produces HaHaHa — it repeats the string three times in a row. This is very different from multiplying numbers! When Python sees a string on one side and a number on the other, it knows you want repetition rather than arithmetic.
"=-" * 15? What happens if you try "Hello " * 5 (notice the space after “Hello”)? Experiment with repeating different characters to create interesting patterns.
Example 5: Escape Characters
What if you want your text to appear on multiple lines from a single print() statement? Or what if you want to add a tab space? Python uses special codes called escape characters for this. They all start with a backslash (\).
# \n creates a new line
print("Line one\nLine two\nLine three")
# \t creates a tab (indent)
print("Name:\tAlex")
print("Age:\t15")
print("Subject:\tComputer Science")
# Combine both!
print("\n--- Report Card ---")
print("Maths:\t\tA")
print("English:\tB")
print("Science:\tA*")
The \n escape character creates a new line — it’s like pressing Enter inside your string. The \t escape character inserts a tab, which is useful for lining things up neatly in columns. These are called “escape” characters because the backslash tells Python to escape from treating the next letter as a normal character.
\t to align the columns. Can you use \n to print your full address on separate lines using just one print() statement?
Example 6: Multiple Arguments in print()
So far, we’ve put one thing inside the print() brackets each time. But you can actually give print() multiple arguments by separating them with commas. Python will print them all on the same line with a space between each one. This is incredibly handy for mixing text and numbers together.
# Mixing text and numbers
print("Score:", 100)
# Combining text with a calculation
print("Hours in a week:", 7 * 24)
# Multiple items separated by commas
print("My name is", "Alex", "and I am", 15, "years old")
# Useful for showing results
print("Half of 99 is", 99 / 2)
When you separate items with commas inside print(), Python automatically puts a space between each item. Notice that you don’t need quotation marks around numbers — only around text. This makes it easy to combine descriptive labels with calculated results in your output.
print("2 + 2 =", 2 + 2)?
How Does It Work?
What is a Program?
A program is simply a set of instructions that a computer executes in order. Think of it like a script for a play — the actors (the computer) follow the directions exactly as written. Each instruction tells the computer to do one specific thing: display some text, perform a calculation, make a decision, and so on.
The programs you wrote above were short — just a few lines — but real programs can be thousands or even millions of lines long. Video games, social media apps, and the website you’re reading right now are all programs at heart.
What is Python?
Python is a programming language — a set of rules and vocabulary for writing instructions that a computer can understand. It was created by Guido van Rossum in 1991 and named after the comedy group Monty Python (not the snake!).
Python is one of the most popular languages in the world because:
- It reads almost like English, making it great for beginners
- It is used by professionals at companies like Google, NASA, Netflix, and the NHS
- It can do almost anything: websites, games, data science, artificial intelligence, and more
How Does print() Work?
print() is a function built into Python. A function is like a mini-program that performs a specific job. When you write print("Hello"), you are calling the print function and giving it the text "Hello" to display. The text inside the brackets is called an argument — it’s the data you’re handing to the function so it knows what to do.
You can think of print() as a loudspeaker for your program. Without it, your code might be doing calculations and processing data behind the scenes, but you won’t see any of it. The print() function is what makes the invisible visible — it takes whatever you give it and displays it on the screen for you to read.
Text vs Numbers
You might have noticed an important difference in the examples above:
print("2 + 3")— with quotation marks, Python displays the text2 + 3exactly as writtenprint(2 + 3)— without quotation marks, Python calculates the answer and displays5
Quotation marks tell Python “this is just text, don’t try to do anything clever with it.” Without them, Python treats the content as code to be evaluated.
Where is Python Used in the Real World?
You might be wondering: “This is interesting, but what can Python actually do in the real world?” The answer is: an enormous amount. Python is one of the most widely used programming languages on the planet, and it powers some of the technology you use every single day.
Web Development: Some of the world’s biggest websites are built using Python. Instagram, the photo-sharing app used by over a billion people, runs its entire back-end on Python. YouTube also uses Python extensively to serve videos to millions of viewers every hour. Python’s web frameworks, such as Django and Flask, allow developers to build powerful websites quickly and reliably.
Data Science and Artificial Intelligence: Python is the language of choice for data scientists and AI researchers worldwide. When Netflix recommends a film it thinks you will enjoy, that recommendation system is built with Python. Hospitals and research laboratories use Python to analyse medical data and identify patterns that help doctors diagnose diseases earlier. Machine learning — the technology behind voice assistants like Siri and Alexa — is predominantly developed in Python.
Games: While most big-budget games are built in languages like C++, Python plays a significant role in the gaming world. Minecraft supports Python-based modding through various community tools, allowing players to write code that changes how the game works. The strategy game Civilisation IV used Python for much of its game logic and modding system. Python is also widely used for creating game prototypes and smaller indie games.
Space Exploration: This is where things get really exciting. NASA uses Python for everything from mission planning to analysing data sent back from Mars rovers. SpaceX uses Python in its flight software testing processes. The first-ever image of a black hole, captured in 2019, was processed using Python code. When you learn Python, you are learning the same language that helps humanity explore the universe.
Education: Python is now the most taught first programming language at universities worldwide. It is used in GCSE and A-Level Computer Science courses across the UK, and it is the recommended language for many exam boards including OCR, AQA, and Edexcel. Its clear, readable syntax makes it the ideal language for learning the fundamentals of programming before moving on to other languages.
Worked Example: Building a Greeting Card
Let’s walk through building a small program step by step. We want to create a simple greeting card that displays a bordered message with some personalisation and a fun calculation. This will combine everything you have learned so far: print(), strings, comments, arithmetic, and multiple arguments.
Step 1: Start with a comment describing what the program does. Comments make your code easier to understand for anyone reading it — including your future self!
Step 2: Create a decorative border using string repetition.
Step 3: Print the greeting message using plain text strings.
Step 4: Add a fun fact using a calculation with multiple arguments in print().
Step 5: Close with another border line to complete the card.
Here is the finished program. Read through each line and make sure you understand what it does before you run it:
# Greeting Card Program
# This program displays a personalised greeting card
# Step 2: Top border
print("=" * 35)
# Step 3: Greeting messages
print(" Happy Birthday, Alex!")
print(" Wishing you a fantastic day!")
print()
# Step 4: Fun facts with calculations
print(" Fun fact: you are now", 15 * 365, "days old!")
print(" That's about", 15 * 365 * 24, "hours!")
print()
# Step 5: Closing message and bottom border
print(" From your friends in Python class")
print("=" * 35)
Let’s break down what each part does:
- Lines 1–2: Comments explaining the purpose of the program. Python ignores these entirely.
- Line 5:
"=" * 35repeats the equals sign 35 times to create a decorative border line. - Lines 8–9: Simple
print()statements displaying text strings. The spaces at the start add indentation for visual appeal. - Line 10:
print()with empty brackets prints a blank line, adding spacing. - Lines 13–14: These combine text and arithmetic using commas. Python calculates
15 * 365and15 * 365 * 24and displays the results alongside the text. - Line 18: Another repeated string to close the border at the bottom of the card.
= to something else, like * or #.
Common Mistakes
Print("Hello") with a capital P will cause an error — Python is case-sensitive, so print and Print are completely different words to it. Always use lowercase print.
Here are some of the most common mistakes that beginners make. Learning to spot these early will save you a lot of frustration!
Mistake 1: Forgetting quotation marks around text
# This will cause an error!
print(Hello)
Without quotation marks, Python thinks Hello is the name of a variable or function, not a piece of text. Since nothing called Hello has been defined, Python raises a NameError. The fix is simple — add the quotation marks: print("Hello").
Mistake 2: Mismatched quotation marks
# This will cause an error!
print("Hello')
You started with a double quotation mark (") but ended with a single one ('). Python requires you to use the same type of quotation mark at both ends. Either "Hello" or 'Hello' will work, but you must be consistent within each string.
Mistake 3: Missing brackets (parentheses)
# This will cause an error!
print "Hello"
In Python 3 (the version we are using), print() is a function, and functions always need brackets around their arguments. Writing print "Hello" without brackets was valid in an older version of Python (Python 2), but it causes a SyntaxError in Python 3. Always include the brackets: print("Hello").
Key Vocabulary
Here are the important terms introduced in this chapter. Make sure you understand each one — they will appear again and again throughout the course.
| Term | Definition |
|---|---|
| Program | A set of instructions that a computer follows in order to complete a task or solve a problem. |
| Programming Language | A formal set of rules and vocabulary used to write instructions that a computer can understand and execute. |
| Python | A popular, high-level programming language known for its readability and versatility. Created by Guido van Rossum in 1991. |
| print() | A built-in Python function that displays text, numbers, or other data on the screen. |
| String | A piece of text in Python, written inside quotation marks. For example, "Hello" is a string. |
| Argument | A value passed to a function inside its brackets. In print("Hello"), the string "Hello" is the argument. |
| Comment | A note in your code that Python ignores, written after a # symbol. Used to explain code to human readers. |
| Syntax | The rules that define how Python code must be written. Like grammar in English, syntax errors occur when these rules are broken. |
| Bug | An error or mistake in a program that causes it to behave unexpectedly or produce incorrect results. |
| Debugging | The process of finding and fixing bugs in a program. A core skill for every programmer. |
| Sequential Execution | The way Python runs code from top to bottom, one line at a time, in the exact order it is written. |
| Function | A reusable block of code that performs a specific task. print() is an example of a built-in function. |
Your Turn
Make the computer introduce you! Replace the blank below with your actual name so that when you run the code, it prints a greeting with your name in it.
STEP 2: Replace the ____ with your first name (keep the quotation marks!)
STEP 3: Click Run Code to see your greeting
# Replace ____ with your name
print("Hello, my name is ____!")
print("Hello, my name is Priya!"). Make sure you keep both quotation marks and the brackets.Use at least 3 print statements to create a simple picture or pattern using text characters. This is called ASCII art — art made entirely from keyboard characters. Here are some ideas: a house, a face, a rocket, or a simple tree.
STEP 2: Write one print() statement for each line of your picture
STEP 3: Use characters like * - / \ | _ ( ) ^ to build your design
STEP 4: Run the code and adjust until it looks right
# Create your ASCII art below
# Here's an example of a simple cat face to get you started:
print(" /\_/\ ")
print(" ( o.o ) ")
print(" > ^ < ")
# Now try making your own!
Each print() statement creates one line of output. Think of your picture row by row. Here is a simple tree you could try:
print(" * ")
print(" *** ")
print(" ***** ")
print("*******")
print(" | ")
Use spaces inside the quotation marks to position your characters. The key is to experiment — there is no single right answer!
Write a program that prints a short story using at least 5 print statements. It could be a mini adventure, a joke with a punchline, a poem, a description of your day, or anything you like. Be creative! You can also mix in some maths calculations if you want to include numbers in your story.
STEP 2: Write each line as a separate print() statement
STEP 3: Consider adding blank lines with print() (no text) for spacing
STEP 4: Optionally mix in a calculation, e.g. print("I have", 3 + 4, "pets")
STEP 5: Run your program and read through the output
# Write your short story here
# Use at least 5 print() statements
# Be creative and have fun!
Here are some ideas to get you started:
- A mini adventure: “You wake up in a mysterious forest...”
- A joke: Build up to a punchline across several lines.
- A poem: Write a short rhyming poem, one line per print statement.
- Fun fact list: Use calculations like
print("There are", 365 * 24, "hours in a year!")
Remember: you can print a blank line with just print() (empty brackets) to add spacing between parts of your story. There is no wrong answer here — the goal is to practise using print() and to have fun doing it!
Use Python as a calculator to answer some real-world maths questions. For each question, write a print() statement that includes a label (text) and the calculation. We have started the first one for you.
STEP 2: Work out how many days old you are (your age in years × 365)
STEP 3: Convert your height from centimetres to millimetres (multiply by 10)
STEP 4: Add a bonus calculation of your own choosing
STEP 5: Run the code and check the answers make sense
# Real-world Python calculations
# How many seconds are in a day?
# (Hint: 60 seconds x 60 minutes x 24 hours)
print("Seconds in a day:", 60 * 60 * 24)
# How many days old are you?
# Replace __ with your age
print("I am approximately ____ days old")
# What is your height in millimetres?
# Replace __ with your height in cm
print("My height in mm is ____")
# Bonus: add your own real-world calculation!
For the “days old” question, use commas to mix text and a calculation. For example, if you are 15 years old:
print("I am approximately", 15 * 365, "days old")
For the height question, if you are 165 cm tall:
print("My height in mm is", 165 * 10)
For your bonus calculation, try something like: How many lessons do you have in a school year? How many steps do you walk in a week? How many slices of toast have you eaten in your life?
Use print() to create a menu for a restaurant or café. Your menu should include a title, at least 5 items with prices, and some formatting to make it look professional. You can use string repetition for borders, \t for alignment, and blank lines for spacing.
STEP 2: Print at least 5 menu items, each with a name and price
STEP 3: Use \t (tab) or spaces to align prices neatly
STEP 4: Add section headings (e.g. Starters, Mains, Desserts)
STEP 5: Close with a border and a message (e.g. “Thank you for visiting!”)
# Create your restaurant or cafe menu here
# Use borders, tabs, and spacing to make it look great!
print("=" * 30)
print(" Welcome to ____")
print("=" * 30)
# Add your menu items below
Here is an example of how you might format part of a menu:
print("--- Drinks ---")
print("Tea\t\t£1.50")
print("Coffee\t\t£2.00")
print("Hot Chocolate\t£2.50")
The \t characters create tab spaces, which help line up the prices. Use "=" * 30 or "-" * 30 to create neat divider lines. Think about what kind of restaurant you want — a pizza place, a sushi bar, a cake shop — and have fun designing the menu!
Think About It
Take a moment to think about what you’ve learnt in this chapter. Try to answer these questions in your head or discuss them with a classmate:
- In your own words, what is a program? Can you think of three real-world examples of “programs” that don’t involve computers?
- Why does the order of instructions matter? What would happen if a recipe told you to “put the cake in the oven” before “mix the ingredients”?
- What is the difference between
print("5 + 3")andprint(5 + 3)? Why does Python treat them differently? - Why is it important that computers follow instructions exactly as written? Can you think of situations where this is a good thing, and situations where it could cause problems?
- What surprised you most about writing your first Python programs?
- Programming is giving a computer a precise set of instructions to complete a task.
- Python is a popular, beginner-friendly programming language used by professionals worldwide.
- The
print()function displays text and numbers on the screen. Text must be placed inside quotation marks (making it a string). - Python executes code from top to bottom in order — this is called sequential execution.
- Python can perform arithmetic and follows the standard order of operations (BIDMAS/BODMAS).
- Comments (lines starting with
#) are notes for humans that Python ignores. They help make your code readable and understandable.
Exam-Style Questions
Test your understanding with these exam-style questions. Try to write your answer before clicking to reveal the mark scheme.
Mark scheme:
- A programming language is a formal set of rules/vocabulary (1 mark) used to write instructions that a computer can understand and execute (1 mark).
Example answer: A programming language is a set of rules and keywords that allows a human to write instructions in a structured way that a computer can interpret and carry out.
Mark scheme:
- Sequential execution means that the computer runs each line of code one at a time (1 mark), from top to bottom in the order they are written (1 mark).
Example answer: Sequential execution means that Python processes instructions one line at a time, starting from the first line and working its way down to the last line, executing each instruction in the exact order it appears in the code.
print() function in Python? (1 mark)Mark scheme:
- The
print()function outputs/displays data (text, numbers, or other values) to the screen (1 mark).
Example answer: The print() function is used to display information on the screen so the user can see the output of the program.
Extra Resources
Want to explore programming further? Try these trusted resources:
- Python Block Editor — Build Python programs by dragging and dropping visual blocks
- Programming Mindmap — See how all programming concepts connect together
- GCSE Topic 1: Computational Thinking — Algorithms, pseudocode, and flowcharts with runnable Python examples
- BBC Bitesize: Edexcel Computer Science — Revision notes and quizzes aligned with the Edexcel GCSE specification
- W3Schools: Python Introduction — Interactive tutorials and examples you can edit and run online
- Python.org Official Tutorial — The official Python tutorial, straight from the people who make the language
What’s Next?
So far, your programs display information and then it’s gone. But what if you wanted the computer to remember something — like a player’s name, a score, or the result of a calculation — so you could use it later? In Chapter 2: Variables & Data Types, you’ll learn how to store information in variables, which are like labelled boxes where your program can keep data. This is where things start to get really powerful!