0% found this document useful (0 votes)
6 views

G7_for_loop_WS_02 - MS

The document provides an overview of the for loop in Python, including true/false statements, fill-in-the-blanks, multiple choice questions, and short answer questions. It explains how for loops iterate over sequences, the use of break and continue statements, and includes examples for clarity. The content is structured to assess understanding of the for loop's functionality and syntax.

Uploaded by

j.a.nafi2011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

G7_for_loop_WS_02 - MS

The document provides an overview of the for loop in Python, including true/false statements, fill-in-the-blanks, multiple choice questions, and short answer questions. It explains how for loops iterate over sequences, the use of break and continue statements, and includes examples for clarity. The content is structured to assess understanding of the for loop's functionality and syntax.

Uploaded by

j.a.nafi2011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Name:

Grade: 7 Section:

Teacher: Thouhidul Islam Date:

Topic: Python Module A: FOR LOOP

Section A: True/False

1. True - A for loop in Python is used to iterate over a sequence such as a list, tuple, or string.
2. True - The for loop will stop executing once it reaches the end of the sequence.
3. True - In a for loop, the loop variable is updated automatically with the next item in the sequence on
each iteration.
4. True - You can use the break statement to stop the for loop before it has iterated over all the items in
the sequence.
5. False - A for loop can iterate over various data types, including strings, lists, tuples, and not just
numerical ranges.

Section B: Fill in the Blanks

1. A for loop in Python is used to iterate over a sequence of elements.


2. The loop variable in a for loop takes each value from the sequence on each iteration.
3. The break statement can be used to stop the loop before it goes through all elements in a sequence.
4. To skip the current iteration in a for loop and move to the next, use the continue statement.
5. The for loop automatically ends when there are no more elements to iterate over.

Section C: Multiple Choice Questions (MCQs)

1. b) It iterates over a sequence of elements - This is the correct description of a for loop.
2. c) It is updated to the next item in the sequence - The loop variable is updated with the next item from
the sequence on each iteration.
3. c) break - The break statement is used to exit the loop before it completes all iterations.
4. c) Skips the current iteration and moves to the next - The continue statement skips the current
iteration and moves to the next one.
5. c) for x in range(1, 6): - This is the correct syntax for a for loop in Python.
Section D: Short Answer Questions

1. Explain how a for loop works in Python and provide an example of iterating over a list of numbers.
A for loop in Python is used to iterate over a sequence of elements, such as a list, string, or range. On
each iteration, the loop variable is assigned the next value from the sequence, and the code block inside
the loop is executed. Example:

numbers = [1, 2, 3, 4, 5]
for num in numbers:
print(num)

2. Describe a situation where you might use the break statement in a for loop. Provide an example.
You might use the break statement in a for loop when you want to exit the loop early, based on a
certain condition. For instance, if you are searching for a specific item in a list, you can stop the loop once
you find it. Example:

numbers = [1, 2, 3, 4, 5]
for num in numbers:
if num == 3:
break
print(num)

You might also like