Computers · Lesson 7

Thinking Like a Coder

Coders solve big problems by breaking them into small, clear steps. Learn step-wise thinking, algorithms and flowcharts, loops and debugging, then code with blocks in Blockly and Scratch — and command the LOGO turtle in a live lab!

~45 min read8 quick checksLive LOGO labTest: 20 questions

1Step-wise thinking

Every task you do — brushing your teeth, making a paper rabbit, solving a sum — has a sequence of steps. Doing them in the right order makes even hard tasks easy.

Reasoning
Thinking logically to solve problems, produce creative ideas and set goals.
Problem solving
Converting a complex (big, difficult) task into simple steps to reach the goal.
Step-wise thinking
Planning and doing a task one step at a time, in the correct order.
✏️ Worked example — a birthday party
  1. Make a list of guests and send them invitations.
  2. Arrange seating and food for them.
  3. Welcome the guests and enjoy the party.

If you skip step 1, you won't know how many guests are coming, so seating and food will go wrong and the party ends up in a mess!

Case studies

🚌 The school trip

Should the teacher book the bus seats first, or collect students' names first? Names first — then he knows exactly how many seats to book.

💎 The diamond chest

Three chests; all clues are true: "Not in Chest 2." "In Chest 1 or Chest 3." "Not in Chest 3." Cross out 2 and 3 → the diamond is in Chest 1.

✏️ Worked example — three sisters

Alice, Elsa and Dora are sisters. Alice is not the youngest. Elsa is the eldest. Dora is not the eldest.

  1. Elsa is the eldest (clue 2).
  2. So Alice is either middle or youngest — but she is not the youngest, so Alice is the middle one.
  3. Only one place is left: Dora is the youngest.

Tip: start with the clue that tells you something for sure, then cross out.

Put these steps to start a car in the correct order.
P: Turn on the engine · Q: Open the car door · R: Close the car door · S: Sit on the driver's seat

  1. P, Q, S, R
  2. Q, S, R, P
  3. S, Q, R, P
  4. Q, R, S, P
First open the door (Q), sit down (S), close the door (R), and only then turn on the engine (P).

2Computational thinking

Computer scientists use four "thinking tools" to solve problems. Together they are called computational thinking.

🧩DecompositionBreak a bigproblem intosmall parts 🔁PatternsSpot what isthe same orrepeats 🎯AbstractionKeep what isimportant, ignoreextra details 📋AlgorithmWrite clearsteps in theright order Four tools of computational thinking
Decomposition · Pattern recognition · Abstraction · Algorithms
✏️ Worked example — drawing a house in LOGO
  • Decomposition: a house = a square (walls) + a triangle (roof) + a door.
  • Patterns: a square is "go forward, turn 90°" four times; a triangle is "go forward, turn 120°" three times.
  • Abstraction: the colour of the curtains doesn't matter for the shape — leave it out.
  • Algorithm: draw the square, move to the top, draw the triangle, move down, draw the door.

Tara plans her school project by splitting it into: find facts, draw pictures, write paragraphs, make the cover. Which tool is she using?

  1. Decomposition
  2. Abstraction
  3. Debugging
  4. Net surfing
Breaking one big task into smaller parts is decomposition.

3Algorithms & flowcharts

An algorithm is a clear, step-by-step set of instructions to solve a problem or finish a task — like a recipe. A computer program is an algorithm written in a language the computer understands.

✏️ Worked example — algorithm to make a cup of hot chocolate
  1. Start.
  2. Heat a cup of milk.
  3. Add 2 spoons of cocoa and 1 spoon of sugar.
  4. Stir well.
  5. Pour into a mug and serve.
  6. Stop.

Flowchart symbols

A flowchart is a picture of an algorithm. Each kind of step has its own shape, and arrows show the order.

Start / End Input / Output Process Yes/No? Flow line A Oval (terminal)ParallelogramRectangle Diamond (decision)Arrow (direction)Circle (connector) 2 exits: Yes and Noread / print dataan action or calculation joins parts of a chart
The six flowchart symbols you need to know.
Remember: Oval = Open and close (Start/End). Diamond = Decide. Rectangle = Run an action. Parallelogram = Put in / Print out.

A flowchart with a decision

StartLook outsideRaining? YesNo Take umbrellaWear a cap Go to schoolEnd
The diamond asks a Yes/No question, so the path splits into two.
⚠️ Olympiad trap

Students mix up the shapes. A decision is always a diamond (never a rectangle), and Start/End is an oval. Input/Output (like "Input marks" or "Print result") is a parallelogram.

In a flowchart, the step "Add 5 to the number" should be drawn in which shape?

  1. Oval
  2. Diamond
  3. Rectangle
  4. Parallelogram
Adding is an action (a process), so it goes in a rectangle. A diamond is only for Yes/No questions.

4Sequence, loops, conditions & events

Almost every program is built from four simple ideas.

IdeaMeaningEveryday example
SequenceSteps done one after another, in orderWear socks, then shoes
Loop (repeat)Doing the same steps again and againSkip the rope 10 times
Condition (if…then…else)Choosing what to do based on a questionIf it rains, take an umbrella, else wear a cap
EventSomething that starts an actionWhen the bell rings, go to class. When the green flag is clicked, start.
✏️ Worked example — counting in a loop

repeat 3 times: [ move forward, turn right ] then move forward. How many moves forward?

  1. Inside the loop there is 1 move, done 3 times → 1 × 3 = 3.
  2. One more move after the loop → 3 + 1 = 4.
⚠️ Olympiad trap

When counting, multiply only the blocks inside the loop by the number of repeats. Blocks outside (before or after) run just once.

How many times will the character jump? jump, then repeat 4 times: [ jump, jump ]

  1. 5
  2. 6
  3. 8
  4. 9
Inside the loop: 2 jumps × 4 = 8. Plus 1 jump before the loop: 8 + 1 = 9.

5Debugging — finding and fixing mistakes

A mistake in a program or in a list of steps is called a bug. Finding and fixing it is called debugging. Even the best coders make bugs — good coders test and fix them.

🌟 Did you know?

In 1947, Grace Hopper's team found a real moth stuck inside the Harvard Mark II computer. They taped it in their logbook as the "first actual case of bug being found" — which made the word bug famous!

✏️ Worked example — spot the bug

Steps to post a letter: 1. Write the letter · 2. Drop the envelope in the post box · 3. Put the letter in the envelope · 4. Stick a stamp on the envelope.

  1. Read the steps one by one and "act them out" in your head.
  2. At step 2 the envelope is still empty and has no stamp! Step 2 is in the wrong place.
  3. Fixed order: 1, 3, 4, 2 — write, put in envelope, stamp, then post.

6Block coding: Blockly Games & Scratch

In block coding you don't type code — you drag and drop colourful blocks that snap together like puzzle pieces.

Blockly Games

Blockly is a web-based platform with coding games. Open https://blockly.games in a browser. You will see games like Puzzle, Maze, Bird, Turtle, Movie, Music, Pond Tutor and Pond.

🧩 Puzzle

Teaches how blocks connect. Click the drop-down to choose the number of legs, drag the right trait blocks to each animal or bird, then click Check Answers.

🧭 Maze

Teaches movement and logic. Join move forward, turn left/right and repeat blocks, click Run Program, and reach the marker to see Congratulations!

🐦 Bird

Teaches angles. Use the heading block (e.g. heading 45°) to fly the bird to the worm, then to the nest.

🐢 Turtle

Draw shapes with a turtle using blocks — just like LOGO!

move forwardmove forwardturn left ↺move forward ▶ faces right · ◯ goal
Two moves right, turn left (to face up), one move up — goal reached!
⚠️ Olympiad trap

"Turn left" and "turn right" depend on the way the character is facing, not on your screen. A character facing down that turns left ends up facing right on the screen! Pretend you are the character.

Scratch

Scratch is a free block-coding language made by the MIT Media Lab (scratch.mit.edu). You make stories, games and animations.

Sprite
A character or object that follows your code — like the orange Scratch Cat.
Stage
The background area where sprites move and act.
Blocks
Grouped by colour: Motion, Looks, Sound, Events, Control, Sensing, Operators, Variables and My Blocks.
Green flag
The event "when green flag clicked" starts the program; the red stop sign stops it.
Script
A stack of blocks joined together.

In Blockly's Maze game, which button do you click to make the character follow your blocks?

  1. Check Answers
  2. Run Program
  3. Green flag
  4. Execute
In Blockly Maze and Bird you click Run Program. (Check Answers is in Puzzle; the green flag is Scratch; Execute is in MSW LOGO.)

8REPEAT and regular shapes

Instead of typing FD 100 RT 90 four times, use a loop: REPEAT 4 [FD 100 RT 90]. The number says how many times; the commands to repeat go inside square brackets [ ].

The turning rule

To draw any regular shape, the turtle must turn a total of 360° to get back to where it started. So:

📌 Remember

Turn angle = 360 ÷ number of sides  ·  REPEAT sides [FD length RT 360÷sides]

TriangleSquarePentagonHexagon 360÷3 = 120°360÷4 = 90°360÷5 = 72°360÷6 = 60°
Each shape starts at the pink dot with the turtle facing up, and uses RT turns.
ShapeSidesTurnCommand
Equilateral triangle3120°REPEAT 3 [FD 100 RT 120]
Square490°REPEAT 4 [FD 100 RT 90]
Pentagon572°REPEAT 5 [FD 80 RT 72]
Hexagon660°REPEAT 6 [FD 60 RT 60]
Octagon845°REPEAT 8 [FD 50 RT 45]
Circle (almost)360 tiny sides1°REPEAT 360 [FD 1 RT 1]
5-pointed star5144°REPEAT 5 [FD 100 RT 144]
⚠️ Olympiad trap

A triangle does not use RT 60! The inside corner of an equilateral triangle is 60°, but the turtle turns by the outside angle: 360 ÷ 3 = 120. Also, the number after REPEAT and the number of sides must match: REPEAT 4 [FD 50 RT 60] does not make a closed square.

🐢 Try it yourself — live LOGO lab

Click a preset or type your own commands and press Enter. Try changing the numbers! This lab understands FD, BK, RT, LT, PU, PD, PE, HT, ST, HOME, CS, SETPC, SETPENSIZE, REPEAT and PRINT.

💡 Tip

Type this to draw a house: REPEAT 4 [FD 80 RT 90] FD 80 RT 30 REPEAT 3 [FD 80 RT 120] — a square for the walls, then from the top-left corner the turtle turns right 30° and draws a triangle for the roof. Can you add a door using PU and PD? The preset with a REPEAT inside a REPEAT spins a square 8 times to make a flower.

Which command draws a regular octagon (8 equal sides)?

  1. REPEAT 8 [FD 50 RT 60]
  2. REPEAT 8 [FD 50 RT 45]
  3. REPEAT 45 [FD 50 RT 8]
  4. REPEAT 6 [FD 50 RT 45]
8 sides → repeat 8 times, turn 360 ÷ 8 = 45° each time. Try it in the lab above!

10Quick recap

Flip cards

QuestionWhich flowchart shape is a decision?
AnswerDiamond (Yes/No exits)
QuestionWhat is debugging?
AnswerFinding and fixing mistakes in a program or steps
QuestionBlockly Bird uses which block for angles?
Answerheading (e.g. heading 45°)
QuestionCharacters in Scratch are called…?
AnswerSprites
QuestionPentagon: REPEAT 5 [FD 80 RT ?]
Answer72 (360 ÷ 5)
QuestionMove without drawing?
AnswerPU (Pen Up)
QuestionPrint GOOD NIGHT correctly
AnswerPRINT [GOOD NIGHT]
QuestionPRINT PRODUCT 4 SUM 2 3 = ?
Answer20 (SUM 2 3 = 5, then 4 × 5)
QuestionA procedure begins and ends with…?
AnswerTO … END
QuestionWhich MSW LOGO button stops a program for a while?
AnswerPause (Halt stops it completely)