Loading preview...

Features

  • Code drawn as blocks, with if-then-else blocks around the steps they choose between
  • Number machines with if-then rules, such as halve even numbers
  • Sort numbers into boxes with conditions, then change the order of the checks
  • Trace repeat and for-each loops with a condition inside
  • Find the line with the bug and write the fix
  • Run two programs that do the same thing and circle the shorter one
  • A worked example on every page
  • Answer keys included

Skills Covered

  • Run code with if-then-else conditions
  • Use conditions to sort numbers
  • Trace loops that have a condition inside
  • Find and fix a bug in code
  • Explain how changing code changes the result
  • Compare two programs and choose the more efficient one

How to Use This Pack

Five pages of coding with no computer. Code is drawn as blocks: an if-then block runs the steps inside it only when its test is true, and its else part runs when the test is false. Page 1 has four number machines with if-then-else rules; students write the number that comes out for each number that goes in. Page 2 sorts ten numbers into boxes A, B and C with a rule of two checks, then asks which numbers change boxes when the checks are swapped. Page 3 traces loops with a condition inside, including for-each loops that count or add up numbers from a list. Page 4 runs each program against its goal, finds the line with the bug and writes the fix. Page 5 runs two programs that give the same result and circles the shorter, more efficient one.

In the Classroom

Act out a number machine: one student holds a card with an if-then rule, others bring numbers to it and the class decides which way each number goes. On page 4, ask students to test the fixed code with a second number before they are sure. Page 5 is a good start for talking about efficient code: fewer steps that do the same job.

At Home

Make up an if-then rule together, such as if the number is even, halve it, else add 1, and take turns giving each other numbers to run through it. Then ask what happens if you start at 10 and keep running the rule.

Tips for Success

  • Check the test first, then run only one side: the then part or the else part
  • Watch the edges: more than 50 does not include 50
  • In a loop, the test is checked again every time round
  • To find a bug, run the code with the test number and see where it goes wrong
  • Two programs are the same only if they give the same result for every number

If-Then Code

5th Grade

Unplugged coding with conditions: if-then-else blocks inside number machines, sorting rules and loops. Students run programs, sort numbers, trace loops, find and fix bugs and choose the shorter of two programs that do the same thing.

Download PDF
Pin

What’s Included

  • 5 worksheets with answer keys
  • Number machines and sorting with conditions
  • Loops with a condition inside
  • Debugging and choosing efficient code
Can’t find what you need?

Tell us what to make next, or build your own with a worksheet maker.

Suggest a worksheet

Free to print and share

This worksheet is free to download, print, copy, and hand out in your classroom or at home. You do not need to create an account, and there are no watermarks on the PDF.