
At this point, you’ve gathered some experience with the basics. Awesome! This next module is slightly more conceptually challenging, but we won’t be diving too deep into it.
Loops are bits of code that repeat some action over and over again for a specified interval and/or until some condition(s) is met. They come in handy for things like running training epochs on AI models!
Flow (short for flow control and another way of saying conditionals) is a bit of code that only activates if (or if not) some condition(s) are met. Flow is not something you will see a lot of in AI code proper, but it is used frequently in data analysis and validation code.
For both of these topics, we’re only going to cover what you need to read and follow the code you find. So relax, and happy coding!
Objectives
By the end of this module, students will be able to:
- Use
forloops to iterate over sequences. - Use
whileloops to repeat code until a condition is met. - Use
if,elif, andelsestatements to control the flow of their code. - Apply loops and flow control to machine learning applications.
Watch
Python Loops
Python Conditionals
Practice and Apply
Read and practice the following Notebooks in Jupyter: 04_loops_and_flow_python_intro.ipynb
Stuck or need to see this in action? Watch the Loops and Flow Control Walkthrough video (22:37).


