GRADE 8
PYTHON
A. TICK [✔] THE CORRECT OPTION:
__________ is a collection of elements, string, list, etc.
✅a. Sequence
To use else with for loop, the structure is known as _________:
✅c. for else
__________ statement can be used to unconditionally jump out of the loop.
✅a. Break
___________ refers to a process of accessing each item of a list one by one.
✅c. Indexing
B. WRITE 'T' FOR TRUE AND 'F' FOR FALSE STATEMENTS:
· The range() is a pre-defined function of Python. TRUE
· The continue statement skips the current iteration, not terminate the loop. FALSE
· By default, indexing in Python starts with zero (0). FALSE
· The append() function adds a new item to the end of the list. TRUE
C.FILL IN THE BLANKS:
· Loop causes a program to be repeated a certain number of times.
· The range function consists of start, stop, and step parameters.
· The colon (:) operator is used to create a slice in Python.
· Two or more lists can be joined using + operator.
D.ANSWER THE FOLLOWING:
1. What do you mean by loop?
A loop is a programming construct that repeats a block of code multiple times until a condition is
met.
2. Explain for loop.
A for loop is used to iterate over a sequence (like a list, string, or range).
Example:
for i in range(5):
print(i)
3. What is while loop? Write its syntax.
A while loop repeats a block of code as long as a given condition is True.
Syntax:
while condition:
# block of code
Example: i = 1
while i <= 5:
print(i)
i += 1