What Programming Is
Learning Objectives
- You can describe programming as giving precise instructions to a computer.
- You can break a small task into smaller steps before writing code.
- You can explain why reading and tracing code is as important as writing it.
This chapter is about what programming is, at a level where the rest of the course can build on it.
Programming Is Precise Problem Solving
Programming is the activity of describing a process so precisely that a computer can carry it out. A computer does not understand goals the way people do. It follows instructions exactly, one step at a time.
This is what makes programming different from ordinary communication. In everyday life, if you say “make me a sandwich,” another person fills in missing details from experience. A computer does not. If the instructions are incomplete, contradictory, or out of order, the result is wrong or the program fails.
This has become slightly less obvious in the age of generative AI. An AI assistant may sometimes guess what you meant even when your request is vague. That does not remove the need for precision. It only shifts where the guesswork happens, and as you will see across the course, guesswork is not a substitute for understanding.
Making tea
0 / 5 points
Arrange the steps of making a cup of tea in the correct order. Have the first step at the top.
When instructions are ambiguous, a computer cannot guess what you meant.
For example, suppose you write step-by-step instructions for making a cup of tea, but you forget a step for turning off the stove. A human would probably guess that you meant to turn off the stove after boiling the water. A computer that is given the set of instructions to follow would not. In programming, you need to instruct the computer to do everything you want, and only what you want.
From Goals to Steps
Suppose the task is: ask the user for their name and greet them.
That sounds simple, but it already contains several smaller steps:
- Ask the user for a value.
- Store that value somewhere.
- Build the greeting text.
- Print the greeting.
This is called problem decomposition: turning a larger task into smaller parts that can be solved one at a time. Good programmers do this constantly. They do not jump directly from a broad description to a finished program. They first identify the pieces.
Decomposition is also one of the most useful tools when working with AI assistants. A vague request like “build me a study log” gives the assistant nothing to anchor on. The same task broken into “ask the user for one entry, store the entry, and print a summary at the end” is much easier to reason about, regardless of who or what is writing the code.
Printing a greeting
0 / 10 points
A first step in many programming courses is to print a simple greeting. In this course, we use the Python programming language. Below, is a program that prints “Hello, World!”, written in Python. Modify the program to print “Hello, Python!” instead.
The final output should be exactly:
Hello, Python!You can “run” the program by pressing the play icon (▶️) in the top right corner of the code editor. Once ready, submit the program to see if it is correct.
Order Matters
Programs run step by step. The order of those steps changes what the program does.
Consider the difference between these two programs:
print("Hello")print("World")and
print("World")print("Hello")Both are valid. They do different things. A large part of learning to program is learning to predict what a given sequence of instructions will actually produce.
Printing in order
0 / 10 points
The program prints a sequence of activities in an order. The current order is a bit inconvenient, as e.g. putting socks on when running might be a bit tricky.
Reorder the print statements so that the activities are printed in a more natural order. Do not change the text being printed, just the order of the print statements.
The final output should be exactly:
Put the socks onPut the shoes onStart runningSyntax Is the Grammar of a Programming Language
Programming languages have rules about how programs must be written. These rules are called syntax. If a program breaks those rules, you will see a syntax error.
A missing parenthesis or a misspelled keyword can be enough to prevent the program from running. Even putting two print commands on the same line causes a syntax error. The following program is not valid:
print("Hello") print("World")Syntax errors are normal. Beginners encounter them often, and experienced programmers do too. The important skill is not avoiding all mistakes. It is learning to read the feedback carefully and correct the problem systematically.
The editor below has a Python program with a syntax error — it is missing a closing parenthesis. Try running the program with the play button. Then read the error message. Then, fix the program and try running it again.
Much of learning programming is learning to read and understand error messages, as well as learning to read programs and predict what they will do. Spotting syntax errors and understanding what they mean is an important part of that process.
Avoiding mistakes
0 / 5 points
The left hand side of the puzzle area has code lines. Some of them have syntax errors.
Drag the lines to the right hand side to create a program that prints the following, without any syntax errors:
Step 1: Study programmingStep 2: ???Step 3: ProfitFrom Thinking to Code
When programming, you are translating your ideas into a form that a computer can interpret. This takes practice. A starting point is to first think through the problem in plain language, and then write code that corresponds to that thinking. The more you practice this translation, the better you will get at it.
Throughout these materials, you will also see exercises where you are asked to write out the steps of a program in plain language, or to e.g. sort lines of plain-language explanations into a logical order.
In some cases, you will even directly see how the plain language explanations translate to code. Below is the first example of such an exercise.
Order natural-language programming steps
0 / 5 points
Drag and drop the natural-language programming steps to the area marked with “Program”. When you drop steps, the exercise generates Python code.Arrange the steps so that the code creates a variable called score, adds 3 and 4 to it, and prints it.
Here, we use variable. We’ll look in bit more detail what variables are later in this part.
Reading Before Writing
In this course, you will not only write code. You will also read code, explain code, trace code, and debug code. This is intentional.
Being able to read a short program and explain what it does is one of the strongest foundations for later programming skill. It also matters when you use AI tools. If an AI assistant suggests code, the question is not “Did the AI sound confident?” The real question is “What does this program do, and how do I know?”
You will return to this stance again in Reading Code You Didn’t Write at the end of this part.
Below is an example of an exercise that focuses on reading code. Try to reason through the program and come up with an explanation of what it does. The exercises is graded by an AI assistant that will give feedback and guide you towards an answer.
Explain in plain language
0 / 10 points
Study the following Python program:
print("****")print("*")print("****")print("*")print("****")Write a plain language description of what the program does. The description should be detailed enough that someone who has never seen the program before could understand what it does and predict its output.
Your answer should mention the shape or the exact lines that are printed. A vague answer such as “it prints stars” is not enough.
Generative AI tools can be helpful for programming, but they are not a substitute for understanding. If you use an AI assistant to write code, you should read the code it produces carefully and make sure you understand it before using it. You should also make sure that the final submitted work reflects your own understanding.
See the Working Practices page for more on the course’s stance on AI assistants and the skills you will develop for working with them across the course.
A Useful Working Habit
Before writing code, it is worth answering a few questions: what is the program supposed to do, what information does it need, what smaller steps does the task contain, and in what order should those steps happen? If you can answer them clearly, writing the code becomes much easier. If you cannot, that is useful information too. It usually means the task needs another round of decomposition before any code is worth writing.
Your own program
0 / 10 points
Write a Python program of your own that prints a message. The message can be anything you like.
The program must print at least one non-empty line.
One possible output:
I am learning Python.Check Your Understanding
- In your own words, what does “problem decomposition” mean?
- Give an example of two instructions whose meaning changes when the order is swapped.
- Why is reading code an important skill, even for someone who already knows how to write code?
AI Study Aid
Create a chapter diagram
We're looking into to what extent AI-generated diagrams could help with studying.
Use this study aid to generate an AI-generated visual summary of the material you just studied.
Each diagram style emphasizes the content in a different way, so you can choose the focus
that feels most useful.
Using the diagram generator is voluntary and does not affect your course progress. We encourage
you to try it out and see if it helps, but it's totally up to you! Your answers help us understand
how to make better study aids in the future.