WorksheetsPython Quiz on For Loops
Total questions: 10
Worksheet time: 5mins
What is the main focus of Challenge 26 - 30 in the lesson?
Variables
For Loop
Conditional Statements
Functions
What is the purpose of a for loop in programming?
To only work with strings
To reduce lines of code and save time
To avoid using loops
To perform different actions on each item
What is the syntax to define a for loop?
for element in array:
for i in list:
for item in sequence:
for x in range(5):
What does a for loop iterate over?
Only lists
A sequence of elements
Only dictionaries
Only strings
What is the importance of maintaining indentation in a for loop?
It makes the code look neat
It increases the speed of execution
It is not important
It helps in avoiding syntax errors
What will be the output of the code: 'numbers = [2, 3, 4, 5] for x in numbers: print(x)'?
2 3 4
2 3 4 5 6
2 3 4 5
3 4 5 6
What is the purpose of using a for loop in Activity 1 Solution?
To calculate the total length
To iterate through a list of whales
To find the maximum value
To count the number of elements
What is the correct way to access 'snake_2' and 'snake_3' in Activity 2 Solution?
snakes[2], snakes[3]
snakes[1], snakes[3]
snakes[1], snakes[2]
snakes[0], snakes[1]
What is the purpose of the Practical Activity 3?
To complete challenges 26 to 30
To write a for loop
To study coding concepts
To log into an account
What is the key point of using a for loop according to the lesson?
To perform different actions on each item
To avoid consistent control flow
To increase code duplication
To reduce lines of code and save time
