How can I do the same operations on many different values?
Objectives
Explain what a for loop does.
Correctly write for loops to repeat simple calculations.
Trace changes to a loop variable as the loop runs.
Trace changes to other variables as they are updated by a for loop.
Lecture
Jupyter Notebook File
Please use the Jupyter notebook named "03RepeatingActionsWithLoops.ipynb" for this lesson. If you haven't downloaded them already, you may find them here.
Key Points
Use for variable in sequence to process the elements of a sequence one at a time.
The body of a for loop must be indented.
Use len(thing) to determine the length of something that contains other values.
You are being redirected to our marketplace website to provide you an optimal buying experience. Please refer to our FAQ page for more details. Click the button below to proceed further.