Session 2

• To create repeat-until loops

• To explain how loops work

• To create if statements

• To identify Python code

• To translate what we know to Python

Introduction (10 mins)

  • You might like to start the session with the questions on slides 2 - 4

  • Ask participants what they think the code on slide 6 does. Answer: it repeats left-right-forwards-forwards until the van reaches its destination.

  • What if those steps don't take the van to the solution, is there any other code to use? Answer: no, the van would either run out of fuel or crash!

  • Slide 7: Loops with conditions Why is the solution on the right better?

  • Answer: Not only is it shorter, but it is also more flexible. There could be many repetitions of left-right-forwards-forwards and this one repeat block would still solve the problem.

  • Participants do levels 29 - 31

Loops with conditions (25 mins)

  • Slide 9: Quiz time There is a partial solution to a route on this slide. Why must the condition (if-statement) be inside a loop? Answer: the question must be asked continuously

  • What other checks do we need to make to complete this level? Answer: We need to check if there is a left turn and if there is, turn that way. Otherwise, we go forwards.

  • Show the video on slide 10

  • Slide 11: Demonstration Using the IF… ELSE IF… ELSE is a little complex at first. Click on the cog and a menu will appear. Drag as many else if blocks to the right (not the code below) as you need, notice that they appear in your code below. You can also drag an else if you need one. Discuss the meanings of these words. What is different about else if and else?

  • Slide 12: Level 34 During this activity, also consider how you could use this long version of the solution to support a pupil struggling with loops. Look for the pattern. Writing the solution on paper can be helpful.

  • Slide 13: Level 34 In this particular route, the only options are forwards and left. There are more forwards than lefts. If we check if there is a road ahead and there isn’t, we can just turn left. There is no need to check if there is a left.

  • It is important to emphasise the importance of efficient code. Computers are so fast that this might not seem important but emphasise the points that computers do very complex tasks and use a lot of hardware resources so the more efficient the code, the faster it will run.

  • Slide 15: Investigate the random levels. They are very useful to occupy pupils who work at a faster rate than others. It is not always beneficial to allow them to move on to a new topic section.

Quiz (5 mins)

  • Use slides 17 - 20 and discuss answers with participants

Traffic Lights (10 mins)

  • Use slides 21 - 22

  • Demonstrate the use of traffic lights in Rapid Router, e.g. Level 44. Note that the check for a red light must be made on every move

Introduction to Python (5 mins)

  • Demonstrate Level 80: Notice that dragging the blocks creates Python code at the bottom. At the moment, you can’t edit this Python code. The code that exists before you start imports the code that is used in Rapid Router and creates a van at the depot.

  • The first line of Python (from van import Van) just gives Python access to the Rapid Router van code; it is a bit like borrowing a book from a library on a specialised subject.

  • Level 81: Terminology Be aware that the term object is an advanced topic. It refers to the concept of object-oriented programming that is not taught in schools until A Level. It is enough to say that my_van represents a van and it can be given instructions like turn left.

  • If there is time, participants should try levels 80 - 82

Summary

  • Reflect on the challenges in this session.

  • Consider the challenges of using more complex loops and traffic lights?

  • Are there any potential misunderstandings with the Python code they will see so far?

Last updated