Return to Dashboard

Knowledge Check: Module 13

Module 13: Loops - Over Data

Test your understanding of iterating over lists and strings.

Passing Score: 6 / 10

Attempts: Unlimited

1Which is the correct syntax to loop through each element in a list called `my_data`?

2In the loop `for value in numbers:`, what does the variable `value` represent during each iteration?

3How would you iterate through each character in a string variable called `message`?

4Consider the code: `word = "Py"; for letter in word: print(letter)`. What is the output?

5You have a list `scores = [88, 92, 100]`. Which loop prints each score on a new line?

6What is the primary purpose of a `for item in sequence:` loop?

7In the statement `for char in "Hello":`, what part is the "iterable"?

8Can you use a `for item in sequence:` loop to iterate over the elements of a tuple? (e.g., `my_tuple = (1, 2, 3)`)

9What is an advantage of using `for element in data:` compared to using `for i in range(len(data)): print(data[i])` for simple iteration?

10The concept of using a `for` loop to process each item without needing to know *how* the items are stored (e.g., index numbers) is an example of which Computational Thinking principle?

Results

Your Score: 0 / 10

Return to Dashboard