Unit 6 - Grade 8 - Revision Paper
Unit 6 - Grade 8 - Revision Paper
Definition of Terms:
Practically all the Repetitive and Simple task in our daily lives can be decompose into
smaller activities.
Count-Controlled Loop – The FOR Loop – these are essential in programming when you
need to repeat a block of code a predetermined number of times.
Comparison Symbols
Kindly take note of the following comparison symbols being used in the Selection (IF-
ELSE and IF-ELIF-ELSE)
Count-Controlled Loop (The FOR Loops)
Syntax:
Python
for variable in range(start, stop, step):
# Code to be executed repeatedly
Examples:
1. Printing Numbers 0 to 4:
Python
for i in range(5):
print(i)
• Explanation: The loop runs 3 times, printing the string each time. _ is used
when the loop variable isn't needed.
• Output:
• Hello, Python!
• Hello, Python!
• Hello, Python!
• Explanation: The loop adds each number from 1 to 5 to the total variable.
• Output:
• Sum: 15
The answer will be an ERROR since there is no 7th element of the Array.
As you can see in the array the name of the array is days, so if you use the name day (no
s), there will be an error.