Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Iteration & Flow

Welcome to the "Iteration & Flow" unit of the Python Academy! In this notebook, you will learn:

  • Flow Control
  • Indentation
  • if-elif-else statements
  • Loops: while and for
  • continue and break
  • List Comprehension

Building a program is essentially defining actions to perform depending on certain conditions. This can be setting up an alarm to trigger at midnight (time >> alarm), a weather forecast app (metereological conditions >> forecast) or discovering business insights from the latest financial reports (financial values >> analysis). Flow Control is what allows you to check for conditions, act accordingly and iterate on repeatable code.

If/elif/else statements and conditionals

In Python, the main concepts for flow control comprise:

  • if a condition do something, or something else

Conditionals

Link to video

For/While loops and break/continue

  • while a certain condition is true, continue iterating until it no longer applies
  • for a specific number of times, repeat the same action
  • manually controlling to continue to the next iteration of a loop, or else break the loop immediately.

Loops

Link to video

Bonus: List/dict/set comprehension

List/dict/set comprehension is one of the things you want to be comfortable with if you want to write decent Python code. In here we present a short introductory video

ShortListComprehension

Link to video

and a more in-depth explannation

LongComprehensions

Link to video