1/4
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What does this loop print?samples = ['sample_A', 'sample_B', 'sample_C']
for s in samples:
print('Processing:', s)
"Processing: sample_A", "Processing: sample_B", "Processing: sample_C" → one line per item
In a for s in samples: loop, what is s?
A temporary variable that takes on each value in samples, one at a time, reassigned each pass → not a fixed name for one item.
What values does i take in for i in range(5):?
0, 1, 2, 3, 4 → five values, starting at 0.
Why does range(5) produce 0 through 4, not 1 through 5?
Same "up to but not including" logic as slicing → range(5) produces exactly as many indices as there are valid positions in a 5-item list.
What's the typical pattern for processing a list of files in a loop?
Loop over the list of filenames, load each one, compute something, and print or store the result → a template for most batch data-processing tasks.