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:

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!

Python Code
print("Hello, World!")
(click "Run Code" to see output)

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.

Try This: Change the message inside the quotation marks to something else, like 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:

Python Code
print("Good morning!")
print("Welcome to Python.")
print("Let's write some code!")
(click "Run Code" to see output)

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.

Try This: Swap the order of the lines around. What happens if you put the last line first? Add a fourth 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.

Python Code
# Addition
print(2 + 3)

# Multiplication
print(10 * 5)

# Division
print(100 / 4)

# A bigger calculation
print(7 + 3 * 2)
(click "Run Code" to see output)

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.

Try This: Use Python to calculate how many hours there are in a year (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.

Python Code
# Repeat text with *
print("Ha" * 3)

# Create a divider line
print("-" * 30)

# Make a simple border
print("*" * 20)
print("*  Hello, World!  *")
print("*" * 20)
(click "Run Code" to see output)

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.

Try This: Can you create a longer border using "=-" * 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 (\).

Python Code
# \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*")
(click "Run Code" to see output)

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.

Try This: Create a small table of your favourite things using \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.

Python Code
# 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)
(click "Run Code" to see output)

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.

Try This: Use commas to print a sentence about yourself that includes your name, age, and a calculation (like how many months old you are). What happens if you write 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:

Did You Know? — Why is it Called “Python”? When Guido van Rossum started creating Python in the late 1980s, he was reading scripts from Monty Python’s Flying Circus, the famous British comedy show. He wanted a name that was short, unique, and slightly mysterious — so he chose “Python.” This is why you will often see silly references to spam, eggs, and parrots in Python tutorials and documentation. The snake logo came later and stuck, but the true origin is comedy, not reptiles!

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.

Key Concept: Sequential Execution Python executes your code from top to bottom, one line at a time. The first line runs, finishes, and then the second line runs, and so on. This is called sequential execution. Understanding this is the foundation of everything else you will learn in programming.

Text vs Numbers

You might have noticed an important difference in the examples above:

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.

Did You Know? — The First Computer Program The very first computer program was written by Ada Lovelace in 1843 — more than 100 years before modern computers existed! Ada wrote detailed instructions for Charles Babbage’s Analytical Engine, a mechanical computing machine that was never fully built. She is widely regarded as the world’s first computer programmer, and every year in October, Ada Lovelace Day celebrates the contributions of women in science, technology, engineering, and mathematics.
Did You Know? — The “Hello, World!” Tradition The tradition of writing “Hello, World!” as your first program dates back to 1978, when Brian Kernighan used it in his book about the C programming language. Since then, nearly every programming textbook and tutorial in the world has started the same way. It has become a universal rite of passage for new programmers — so by running that first example above, you have officially joined a tradition that is almost 50 years old!

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:

Python Code
# 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)
(click "Run Code" to see output)

Let’s break down what each part does:

Try This: Personalise this greeting card! Change the name, the age, and the message. Can you add more lines to the card? Try changing the border character from = to something else, like * or #.

Common Mistakes

Watch out: Many people think computers are “smart” or can “figure things out.” They can’t. A computer is incredibly fast but has zero common sense. It follows your instructions blindly and precisely. If you tell it to do something silly, it will do it without question. If you forget a step, it won’t fill in the gap for you. Every time your program does something unexpected, it’s almost always because the instructions weren’t quite right — and that’s completely normal! Finding and fixing those mistakes is a huge part of programming, and it’s called debugging.
Watch out: Spelling and punctuation matter in Python. Writing 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

Python Code
# This will cause an error!
print(Hello)
(click "Run Code" to see output)

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

Python Code
# This will cause an error!
print("Hello')
(click "Run Code" to see output)

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)

Python Code
# This will cause an error!
print "Hello"
(click "Run Code" to see output)

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

Exercise 1: Introduce Yourself
Guided

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.

Pseudocode:
STEP 1: Look at the print statement below
STEP 2: Replace the ____ with your first name (keep the quotation marks!)
STEP 3: Click Run Code to see your greeting
Your Code
# Replace ____ with your name
print("Hello, my name is ____!")
(click "Run Code" to see output)
Need a hint?
Replace just the four underscores with your name. For example, if your name is Priya, the line would read: print("Hello, my name is Priya!"). Make sure you keep both quotation marks and the brackets.
Exercise 2: ASCII Art
Partially Guided

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.

Pseudocode:
STEP 1: Plan your picture — sketch it on paper or in your head
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
Your Code
# 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!
(click "Run Code" to see output)
Need a hint?

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!

Exercise 3: Tell a Short Story
Open-Ended

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.

Pseudocode:
STEP 1: Think of a short story, joke, or poem (at least 5 lines)
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
Your Code
# Write your short story here
# Use at least 5 print() statements
# Be creative and have fun!

(click "Run Code" to see output)
Need a hint?

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!

Exercise 4: Python Calculator Challenge
Partially Guided

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.

Pseudocode:
STEP 1: Complete the first calculation (seconds in a day)
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
Your Code
# 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!
(click "Run Code" to see output)
Need a hint?

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?

Exercise 5: Create a Menu Display
Open-Ended

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.

Pseudocode:
STEP 1: Print a decorative border or title for your restaurant
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!”)
Your Code
# 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

(click "Run Code" to see output)
Need a hint?

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:

Chapter Summary In this chapter, you have learnt the following key ideas:
  • 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.

Q1: What is meant by the term “programming language”? (2 marks)

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.

Q2: Explain what “sequential execution” means in the context of a Python program. (2 marks)

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.

Q3: What is the purpose of the 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:

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!