🧩 Block coding, Grade 5 · session 4 of 14 · 60 minutes · ⭐ Plus

If and if/else: making decisions

Programs can make choices. An if block checks something, like "is there a path to the left?", and runs its blocks only when the answer is yes. If/else gives a second plan for when the answer is no.

⭐ Unlock with Plus

A complete lesson · 60 minutes

Teach it, see it, practise it, all on this page.

Open this page with your learner and work down it, or press Teach this lesson to go through it one step at a time on a big screen. Every section has something to do.

  1. Warm-up4 min
  2. If7 min
  3. If/else7 min
  4. Decisions in loops7 min
  5. code.org practical: puzzles 14–2018 min
  6. Activity 14 min
  7. Activity 24 min
  8. Activity 33 min
  9. Quiz5 min
  10. Set the project1 min

By the end you can

  • Read an if block and say when it runs
  • Use if inside a loop to turn at the right places
  • Use if/else to choose between two actions

Before you start

  • Repeat until (session 3)

Have ready

  • code.org open in another tab
  • Paper cards marked YES and NO

Grade 5 · ages 9 to 11 · beginner

Warm-up · think first

If it is raining, take an umbrella. Is it raining now? What do you do?

Show the answer

You check first, then decide. If yes: umbrella. If no: you just go. That check is an if.

Teacher tip: Ask three more if-questions about the room: if the light is on, wave; if you have a pencil, hold it up.

More warm-ups for every class →

Part 1 of 3 · learn, see, practise

If: check, then decide

An if block asks a yes or no question.

If the answer is yes, the blocks inside run. If no, they are skipped.

In the maze, Byte can check: is there a path ahead, to the left, or to the right?

Example 1

Byte walks along and must turn up at the corner. How does it know when?

when runrepeat until ⭐move forwardif path to the leftturn left ↺
  1. Each round, move forward, then check: is there a path to the left?
  2. Along the bottom, the answer is no, so Byte keeps going.
  3. At the corner, yes: turn left. Then it walks up to the star.

Answer: repeat until ⭐: move forward; if path to the left: turn left

Practise it

Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.

Warm-up

Warm-up

Core

Stretch 🔥

Answers (for the teacher)
  1. no
  2. yes or no
  3. 7
  4. nothing

⭐ Part of Pure Faith Plus

The rest of this lesson is in Plus

You have seen the plan, the warm-up and part 1. With Plus you also get:

  • Part 2: If/else: two plans, with practice at three levels
  • Part 3: Decisions inside loops, with practice at three levels
  • Class activity 1: Yes or no robot
  • Class activity 2: If in real life
  • Class activity 3: Predict Byte
  • A 8-question quiz
  • After-class project: Choose-your-path comic
  • Homework and a printable practice sheet with answers
  • Teach mode and the minute-by-minute teacher's plan

The first 2 lessons of every course, every game and all maths practice stay free.

That is ₹208 a month for every lesson of every course. Prefer a teacher? Ask about live classes.

FAQ

If and if/else: making decisions: questions

What is an if statement for kids?

A block that asks a yes or no question and runs its blocks only when the answer is yes.

What is if/else?

An if with a second part that runs when the answer is no, so exactly one of the two always runs.

Which code.org puzzles practise if blocks?

In the Classic Maze, if appears around puzzle 14 and if/else around puzzle 18; puzzle 20 ends with a certificate.

Start a conversation

Want a teacher to take this class?

Tell us the learner's age and level. A teacher from our network teaches with these lessons; we confirm timing and price first.

  • Tell us the learner’s age or grade and goals
  • We’ll suggest a suitable class or learning path
  • We’ll confirm format, timing and fees with a parent or guardian

For a child’s class, please have a parent or guardian send the enquiry. Avoid sharing passwords or sensitive personal details.

We’ll use your details only to respond to this request.

Chat on WhatsApp
Esc

Try