Idea 7of 23Builds onCounting with a loop
A loop can make a pattern
What happens when OUTPUT is inside a loop?
Today you'll discover
- what the loop body is
- how OUTPUT in a loop makes a pattern
- why the order inside matters
Think firstSET 3, then REPEAT 5 TIMES: OUTPUT, ADD 4
OUTPUT is inside the loop now. What does the code show?
Decide first, then press Next. Inside the loop, read OUTPUT before ADD.
Code: SET 3, REPEAT 5 TIMES with OUTPUT and ADD 4 inside, END. Bars for the number at the start and after each pass: 3, 7, 11, 15, 19, 23. A line along the bottom lists what OUTPUT showed: 3, 7, 11, 15, 19. The last step asks what SET 50 with OUTPUT and SUBTRACT 6 inside a 4-pass loop shows.
See the whole ideathe big idea and the key word, in one place
The big idea
OUTPUT inside the loop body shows the number on every pass, which makes a pattern.
Back to pattern rulesStart at 3 and add 4 each time: the same pattern rule as in patterning, written as code.
Compare themOUTPUT inside the loop shows a number on every pass. OUTPUT after END shows just one number, at the end.
Key word
- loop body
- the lines inside a loop, between REPEAT and END, which run on every pass
Ready to use it?
- Say what pattern a loop with OUTPUT inside will show.