Grade8_IT_Q3_Notes_with_Practice
Grade8_IT_Q3_Notes_with_Practice
These notes will help you prepare for your IT Q3 assessment. Read through the examples carefully,
try the practice tasks, and then check the solutions provided at the end.
A loop repeats a block of code multiple times. There are two types of loops in Python: for loops and
while loops.
1. **For Loop**: Used when you know how many times you want to repeat the code.
Example:
print("Hello!")
2. **While Loop**: Used when you want to repeat the code until a certain condition is met.
Example:
count = 1
print("Hello!")
count += 1
2. Accumulators
An accumulator is a variable that stores the total of something, like a sum or a product.
Page 1
Grade 8 IT - Q3 Summative Assessment Notes
s=0
s=s+x
print("Sum:", s)
p=1
p=p*x
print("Product:", p)
3. Slicing
word = "computer"
print(word[0:3])
word = "computer"
print(word[0::2])
Page 2
Grade 8 IT - Q3 Summative Assessment Notes
This will print "cmue".
4. Built-In Functions
Python has many built-in functions to help you. Here are some of them:
Example:
2. Write a program that calculates the sum of the first 10 even numbers.
4. Ask the user for a word and print each letter on a new line.
6. Solutions
Page 3
Grade 8 IT - Q3 Summative Assessment Notes
1. Solution:
for x in range(10):
2. Solution:
s=0
s=s+x
3. Solution:
count = 1
print(count)
count += 1
4. Solution:
print(letter)
5. Solution:
p=1
p=p*x
Page 4
Grade 8 IT - Q3 Summative Assessment Notes
print("Product of numbers from 1 to 5:", p)
Page 5