CAS KS2 Bug in the Water Cycle Activity: Use logical reasoning to detect and correct errors in programs Recommended year group: Year 4 (Can be used in Y5/6 to revise Y4 concepts) Activity duration: Approximately 45 mins Cross-curricular links: Science, Geography Concepts and approaches Debugging Logic Programming Overview In this activity pupils are challenged to detect and correct the error in a number of water cycle programs (debugging). They use logical reasoning to do this, comparing what the program should do with what it does do, and systematically homing in on the error (bug) by ‘thinking through’ the code in the program. Pupil Objectives • I can use logical reasoning to debug a program • I can explain how I debugged a program Introduction (5 mins) • Lead a discussion with pupils to explain they will be debugging a number of pupils’ • • • attempts at programming an animation of the water cycle. Can pupils think what the term debugging might mean? Finding an error (bug) and correcting it. Introduce the term logical reasoning. Have pupils heard of either the words ‘logical’ or ‘reasoning’ before? Lead a discussion to elicit pupils’ understanding of these terms? Introduce the learning objectives on slide 2 of the presentation if you wish Optional: recap the stages in the water cycle. See teaching notes for resources if required. Modelling debugging (10 mins) • Display the ‘Water cycle debug challenge – teacher example’ sheet and open the • • ‘Water cycle debug challenge – teacher example’ program. (Online here http:// scratch.mit.edu/projects/39761324/) Discuss the algorithm at the top of debug challenge sheet. This was used to create the program, this is what the program should do. Run the water cycle program, this shows us what the program does do. Explain you are need to determine exactly which steps of the algorithm the programs matches. Run the program several times, getting pupils to help you tick or cross the steps in the algorithm sheet – you should find you get the result below. Tick or a cross against the stages of the algorithm whether the program matches/doesn’t match. KS2 Bug in the Water Cycle Activity page 1/4 CAS •Can pupils predict what might have gone wrong in the program here? What ex- tra code might there be? What code might be missing? Encourage pupils to give reasons for their predictions as you explain that logical reasoning is all about using our knowledge and understanding to explain why something is the way it is. Explain we are now going to look at the program code in more detail (shown below) to try and work out exactly where the bug is in the program. • Pupils will use logical reasoning to find out where the bug is in the code •Model to pupils the process of using logical reasoning to ‘think through’ each line of code in the program, comparing it to the algorithm as you go in order to detect the bug. Note: as pupils become more confident at debugging, they may choose not to trace through all of a program’s code, but make a judgement about where a bug might be based on their review of the program’s output. Ask pupils for suggestions to fill in the ‘What bug did you find? Why is it a bug?’ column. E.g. There is a missing ‘switch to costume’ command. The algorithm says switch to costume condensation but the code for this is not there.’ Ask pupils to suggest what change we need to make to the program to fix the error. Encourage pupils to justify their suggestions to develop their logical reasoning skills. Ask a pupil to make the required change. Add a ‘Switch to condensation command’ as this will display the missing costume from the algorithm, as shown below. Take suggestions and complete the ‘How did you fix the bug?’ column. • • • • • • • • • • • • • • The code once the bug has been corrected. •Re-run the program to check it now matches the algorithm. •Ask pupils to summarise to a partner and feedback their steps in using logical reasoning to detect and correct the bug. The steps they should be taking appear on page 2 of the teacher example and can be displayed for pupils to follow during the main activity. KS2 Bug in the Water Cycle Activity page 2/4 CAS Main activity (25 mins) •Ensure pupils have a copy of the ‘Pupil debugging challenge sheets’ to com- plete and demonstrate how to access the associated Scratch files (either online or opening form where they have been saved to your school network). Show slide 3 of the presentation. Pupils have 25 mins working to debug the 5 pupils’ programs. These should be tackled in order as the programs get progressively more complex. Note: challenge 5 requires pupils to hear sounds being played by the program and contains more than 1 bug. • • Plenary (5 mins) •Lead a class discussion for pupils to explain the bugs they found in each of the programs and how they corrected these. Where some bugs more difficult to detect than others? Why was this? Did all pupils correct the bugs in the same way? Did pupils follow the debugging process? Did they find other ways to debug? Recap the debugging process and the key terms: debugging and logical reasoning. • Differentiation Support: Pupils requiring additional support may work with an additional adult if available or be paired with a more confident partner. If required pupils can also be given a copy of the Scratch commands help sheet which gives hints to help with the main task. Stretch & challenge: Debugging can become significantly more challenging when there are multiple bugs, since the first bug alters the input conditions throughout the remainder of the program. Pupils that complete the main activity can work in pairs to test each others’ debugging skills by planting multiple bugs in one of the programs and challenging their partner to detect and correct them. They should explain to each other what bugs they detected, how they detected them and what changes they made to correct them. Assessment opportunities •Informal teacher assessment of pupils as they tackle the debugging challenge: focus on pupils’ logical approach and ability to explain the bugs they found, why they are bugs and how they corrected them. Summative assessment of pupils’ debugging challenge sheets. • Teaching Notes Concepts and approaches Debugging Debugging is the process of detecting and correcting errors (bugs) in a program or algorithm. In this activity pupils detect the error in the water cycle program. Once they have identified the error, and explained why it is an error, they work out how to correct the code. KS2 Bug in the Water Cycle Activity page 3/4 CAS Logical reasoning Logical reasoning enables us to analyse things and make predictions. At its heart logical reasoning is about explaining why something is the way it is. In this activity pupils use logical reasoning as they analyse how the program output compares with the algorithm. Subsequently, they also use logical reasoning as they systematically ‘think through’ the program code to identify where the bug is, and work out what change needs to be made to correct it. Programming Programming is the process of implementing an algorithm in a computer programming language. This requires an understanding of the commands in the programming language you are working in. In this activity the program has already been created, however as pupils debug the program they’ll further develop their understanding of Scratch commands, making them more effective programmers in the future. Curriculum links Computing: use logical reasoning to detect and correct errors in programs Science: identify the part played by evaporation and condensation in the watercycle (Y4). Geography:describe and understand key aspects of the water cycle. Prior knowledge Pupils should understand what an algorithm is and have experience of implementing algorithms as simple programs in Scratch. Resources (downloaded from webpage) •MIT’s Scratch 1.4 or Scratch 2.0 installed on or accessible from your school network from on a interactive whiteboard (See this guide for how to use our Scratch resources). •‘Water cycle debug challenge – teacher example’ – to be blown up to A3 •Pupil debugging challenge sheets (5 challenges per pupil) •Scratch files: • Water cycle debug challenge – teacher example: http://scratch.mit.edu/projects/39761324/ • Main task debug challenges in Scratch studio: http://scratch.mit.edu/studios/841830/ Scratch commands help sheet • Optional introduction: recapping the water cycle (slide 4) Ask pupils to discuss with a partner what they can recall about how the stages of the water cycle. Ask a selection of pupils to feedback and write up the key stages as shown: • Water runs off land into rivers and into the sea. This is called surface runoff. • The sun heats the water in rivers, lakes and the sea which causes it to turn into water vapour and rise up into the air. This is called evaporation. • As water vapour rises it cools and turns back into liquid water droplets. This is called condensation. • Water droplets join together until they are too heavy to stay in the air and fall back to Earth as rain, hail and snow. This is called precipitation. If pupils need to further recap their knowledge, or have yet to cover this topic, model how to perform a search of the world wide web to find web pages explaining the stages in the water cycle. Related activities Lower KS2 Dinosaur Fossil Animation Upper KS2 Viking Raid Animation KS2 Scratch Maths Quiz KS2 Bug in the Water Cycle Activity page 4/4
© Copyright 2026 Paperzz