![Page 1: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/1.jpg)
LoopsRepetition
![Page 2: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/2.jpg)
Your grade 3 teacher may have read this
book to you.
If they didn’t, I recommend
that you look it up some time.
![Page 3: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/3.jpg)
![Page 4: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/4.jpg)
![Page 5: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/5.jpg)
![Page 6: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/6.jpg)
![Page 7: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/7.jpg)
Without loops, you need to repeat the same step
over and over.
With loops,
the code is more elegant.
![Page 8: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/8.jpg)
Count is the loop stopping variable.
![Page 9: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/9.jpg)
It starts at 0 and stops before it
gets to 5.
![Page 10: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/10.jpg)
The Parts of a Loop
This is on the test and it is on
the exam.
![Page 11: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/11.jpg)
A. Initialize Loop Stopping Variable
The Parts of a Loop
A
![Page 12: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/12.jpg)
A. Initialize Loop Stopping Variable
B. Test Loop Stopping Condition
The Parts of a Loop
A B
![Page 13: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/13.jpg)
A. Initialize Loop Stopping Variable
C. Steps to repeat
B. Test Loop Stopping Condition
The Parts of a Loop
A B
C
![Page 14: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/14.jpg)
A. Initialize Loop Stopping Variable
C. Steps to repeat
B. Test Loop Stopping Condition
D. Progress to the Loop Stopping Condition
The Parts of a Loop
A B
C
D
![Page 15: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/15.jpg)
A. Initialize Loop Stopping Variable
C. Steps to repeat
B. Test Loop Stopping Condition
D. Progress to the Loop Stopping Condition
The Parts of a Loop
A B
C
D
![Page 16: Loops - gorskicompsci.cagorskicompsci.ca/ICS2O/Unit3/ppt1_Loops.pdf · Once upon a time there was a Giant. The Giant squeezed Jack and said, "TELL ME A BETTER STORY OR GRIND YOUR](https://reader035.vdocuments.site/reader035/viewer/2022070713/5ed0c2dcfb805320854bee06/html5/thumbnails/16.jpg)