What a computer does · Computer Basics
What is a computer, and what is it actually doing when you use it?
Course contentsWhy you need it
Phones, laptops, cash machines, game consoles and smart watches look very different, but inside they all do the same three things. Once you see that pattern, every later course (the robot, Python, websites) is just a new way of using it.
You don't need any experience for this course. If you can use a phone, you can follow it. You won't have to write code: at most you'll change a number or a word on the right and press Run.
The intuition
Think of a kitchen.
- Ingredients go in. That's input.
- A cook follows a recipe. That's processing. The recipe is a list of steps.
- A dish comes out. That's output.
A computer works the same way, only millions of times faster, and with one big difference: it follows the recipe exactly. It never guesses what you meant.
| In the kitchen | On a computer | |
|---|---|---|
| Input | ingredients | what you type, tap, say or photograph |
| Processing | the cook following the recipe | the computer following a program |
| Output | the dish | what shows on the screen, plays from the speaker or comes out of the printer |
The parts you can touch (screen, keyboard, the chips inside) are hardware. The instructions are software. Every app on your phone is a program: a recipe someone wrote.
On the right is a tiny program. You don't need to read code yet. Lines that start with # are notes for people, and the computer skips them. Press Run and watch the output appear below it.
Definition
Computer
A computer is a machine that takes input, processes it by following instructions, and produces output.
Program
A program is a list of instructions that tells a computer what to do, one step at a time.
Software means programs. Hardware is the physical machine they run on.
Examples
A tiny adding machine
Try it yourselfThree parts, from top to bottom: input, processing, output. Change 7 or 5 to other numbers and press Run again.
# INPUT 输入: two numbers
a = 7
b = 5
# PROCESSING 处理: add them
total = a + b
# OUTPUT 输出: show the result
print(total)- L2Input: remember the number 7 under the name a.
a = 7 - L3Input: remember 5 under the name b.
b = 5 - L5Processing: work out 7 + 5 and remember the answer as total.
total = 12 - L7Output: show total on the screen.
12
Words work too
Try it yourselfInput doesn't have to be a number. Change Mia to your own name (keep the quotes) and run it.
# INPUT 输入: a name
name = "Mia"
# PROCESSING 处理: build a greeting
greeting = "Hello, " + name + "!"
# OUTPUT 输出
print(greeting)- L2Input: the name. Quotes mark text.
name = "Mia" - L4Processing: glue three pieces of text together.
greeting = "Hello, Mia!" - L6Output: show the greeting.
Hello, Mia!
It never guesses
Try it yourself3 pens cost 4 each, so the total should be 12. But this program says + where it should say times (written * on a computer). Run it: the computer calmly prints 7. It did exactly what it was told.
# INPUT 输入
pens = 3
price = 4
# PROCESSING 处理: oops, + where we meant *
total = pens + price
# OUTPUT 输出
print(total)- L2Input: 3 pens.
pens = 3 - L3Input: 4 each.
price = 4 - L5The instruction says add, so it adds: 3 + 4.
total = 7 - L7It shows 7. A wrong result comes from a wrong instruction, not from a confused computer.
7
Common mistakes
"The computer knows what I mean"
It doesn't. It follows instructions exactly, even silly ones. When a result is wrong, look at the instructions (or the input), not at the machine.
The screen is not the computer
The screen is an output device. The computing happens in chips inside the case, the laptop or the phone. A phone just packs all the parts into one body.
Apps are not magic
Every app, from a game to a map, is a program someone wrote, built from small steps like the ones on the right. That's why you can learn to make them too.
Quick quiz
1. Which of these is an input device?
Show the answer
Answer: B
A microphone takes your voice into the computer. Speakers and screens send things out.
2. A photo app turns your photo black and white. Which part is the black-and-white photo you see at the end?
Show the answer
Answer: C
The photo you chose is the input, removing the colours is the processing, and the result you see is the output.
3. A shop's program printed the wrong total. What is the most likely cause?
Show the answer
Answer: B
Computers don't get tired and don't make decisions of their own. Wrong output almost always means a wrong instruction or wrong input.
Key points
- A computer takes input, processes it by following instructions, and gives output.
- A program is that list of instructions. Every app is a program.
- Computers follow instructions exactly. A wrong result means a wrong instruction or wrong input.
Practice
3 short exercises: think it through, change something and see what happens, then do one yourself. Answers are checked the moment you submit.
- ThinkSpot the output
You ask a smart speaker: "What's the weather tomorrow?" It looks up the forecast online and answers: "Sunny, 25 degrees."
Which part is the output?
- ChangeFix the instruction
This is the pen shop from the examples: 3 pens at 4 each. Fix the processing line so the machine prints the right total,
12. Leave the input lines as they are.On a computer, times is written
*. Press Run to try it, then Submit. - Your turnSort the steps
A cash machine (ATM) does three things:
- A You type your PIN.
- B Cash comes out.
- C The machine checks your PIN and your balance.
Write the letters in the order input, processing, output. For example:
BAC.
Practise this lesson
Open the interactive lesson to edit and run these examples and solve the exercises with instant feedback. Free to start, no sign-up.
Terms in this lesson
| Term | Chinese | Definition |
|---|---|---|
| Input | 输入 | Information that goes into a computer, such as typing, tapping or speaking. |
| Processing | 处理 | What a computer does with input by following instructions. |
| Output | 输出 | What a computer produces for you, such as text on a screen or a sound. |
| Program | 程序 | A list of instructions that a computer follows step by step. |
| Hardware | 硬件 | The physical parts of a computer that you can touch. |
| Software | 软件 | Programs: the instructions that tell the hardware what to do. |