Lesson Aims:
Homework - click here
- Learn what Break and Continue are
- Know the difference between them
- Be able to apply them correctly to a program
Homework - click here
1. Starter:
- Create a simple program that takes the word "MLG Remix" and for each letter adds 10 to a variable called total. The variable starts with a value of 0.
- Create a program which starts with a variable which has a value of 100. While this value is greater than 47, the program prints out the phrase "MLG Remixed", waits 1 second, then skips a line and prints repeats the cycle.
- Name each of the types of loops used
- Where is iteration used and what is it?
Part 1: Break and Continue:
- In this lesson you will learn about Break and Continue and how they are used in Python coding. The code below does not use Break / Continue - run it and identify the errors.
Part 2: Build your own Alarm System:
- Create your own Alarm System in the code box below
- You could add a range of "if" statements
- You could add a number of variables
Part 3: A better way:
- Sometimes you need to exit a loop completely, for example in Part when when the correct password is entered, you want the next part of the code to execute. Python provides break and continue statements to handle such situations and to have good control on your loop.
- Research what Break and Continue do
- Add the break and continue in the code box below
Part 4: Your turn:
- Now create your own examples of break and continue
What have you learnt today?
- Tell another friend what you found hard and why
- What three new skills have you learnt
- List all the 'terminology' that you have heard
- Ask another student what the definition of one of the 'keywords is'