By the end of this lesson you will be able to
- explain, in your own words, what a computer program is
- explain why instructions to a computer must be exact and in the right order
- say what Python is, and why this course teaches it
- run a piece of code on this website for the first time
A computer only does what it is told
A computer cannot guess what you mean. It cannot use common sense, and it cannot fill in a gap the way a person can. It can only follow instructions, written in a language it understands, one step at a time. A program is simply a list of such instructions.
You give exact instructions all the time without thinking of it as programming. Suppose you asked someone who had never made tea before to make you a cup. You might say:
- Boil water in a pan.
- Add two spoons of tea leaves.
- Let it boil for two minutes.
- Add milk and sugar to taste.
- Pour through a strainer into a cup.
Every step matters, and so does the order. Add the milk before boiling and you get a different result. Skip the strainer and you get tea leaves in your cup. A computer follows instructions exactly like this: precisely, in order, with no assumptions of its own.
The instructions a programmer writes are called code, and writing them is called coding. Later in this course you will read words like “program”, “code” and “script” used to mean much the same thing: a set of instructions written for a computer to follow.
Why order and exactness matter
Here are two sets of instructions for crossing a road. Read both before deciding which is safer.
- Look both ways
- Wait for a gap
- Cross
Now the same three instructions, reordered:
- Cross
- Look both ways
- Wait for a gap
The instructions are identical. Only the order changed, and that alone makes the second version dangerous. A person can often notice a badly ordered instruction and correct it. A computer cannot: it will follow the steps precisely as written, in the order given, even into a mistake. This is the single most important idea in programming, and you will see it again in Lesson 1.2, where the order of your instructions decides the order the results appear on the screen.
Which of the two road-crossing lists above would a computer still follow exactly, even though it leads to a bad outcome?
A computer has no sense of “safer”. It runs the instructions it is given, in the order it is given them, whether or not that order makes sense.
What is Python?
Python is a programming language: a way of writing instructions that a computer can follow. There are many programming languages, in the same way there are many human languages, but Python is one of the most widely used in the world. It runs websites, analyses data, powers artificial intelligence tools, and automates everyday tasks in offices everywhere, from Cochin to California.
This course teaches Python for three practical reasons:
- It reads almost like English. A Python instruction to display text looks like
print("Hello"), which is close to saying "show this text" in plain words. - It is used everywhere. The same language you learn here is used by professional software developers, data analysts and researchers.
- It rewards beginners quickly. You will have a working program of your own within the first few minutes of the next lesson.
How this course works
This is a text course with no videos, but it is not a course you only read. Every lesson has boxes of real, working Python code, right here on the page. You read them, run them, change them, and see what happens.
Try it now: tap the blue Run button below the box. The result will appear underneath it.
Notice what just happened: nothing was installed, and nothing was sent to any server. Python ran inside this page, in your own browser, and showed you a result. That is how every code box on this course works, from here to the very last lesson.
You do not yet know what that line of code means; that is exactly what Lesson 1.2 teaches, in detail. For now, try changing the words inside the quotation marks to a sentence of your own, and press Run again.
Normally, using Python means installing it on a computer first. This course avoids that, because it would be one more thing to get right before you had even started. Instead, this page brings a complete copy of Python into your browser the first time you press Run. It takes a few seconds the first time, and is instant afterwards, for the rest of this lesson. Moving to a new lesson loads it again, since each page starts fresh.
What you will build
Programming is learned by doing, not by reading about it, so this course is built around short, real tasks rather than long explanations. Across the coming lessons in this module you will:
- write your first working program, using an instruction called
print - use Python as a calculator
- store information the program can use later, in what programmers call variables
Later modules build on this, through decisions, repetition, and small complete projects. Each lesson assumes only what earlier lessons taught, so if a word is unfamiliar, it will have been explained already or will be explained where it first matters.
Quick check
Three questions to confirm the main ideas before you move on.
1. What is a computer program?
A program is the set of instructions itself, not the machine, and not a guess. The computer follows it exactly.
2. Why does the order of instructions matter to a computer?
A computer has no common sense to fall back on. It runs your instructions exactly as ordered, so a wrong order gives a wrong (or dangerous) result without any warning.
3. What do you need to install on your own computer to do the exercises in this course?
Every code box brings its own copy of Python into your browser the first time you press Run. Nothing is installed on your computer.
Summary
- A program is a list of exact instructions for a computer to follow, one step at a time.
- A computer cannot guess your meaning or notice a mistake in the order of instructions; it follows them exactly as given.
- Python is a widely used programming language, chosen for this course because it reads clearly and rewards beginners quickly.
- Every code box on this course runs real Python inside your own browser. Nothing needs to be installed.
Found a mistake on this page, or something unclear? Report a problem and mention “Python Lesson 1.1”.
