Learn with Yasir

Learn Python, Microsoft 365 and Google Workspace

Home

Share Your Feedback

5. Python: Flow Control Statements

Connect with me: Youtube | LinkedIn | WhatsApp Channel | Web | Facebook | Twitter

5.1 Flow control statements

Flow control statements in Python determine the order in which your code is executed. They allow you to make decisions, repeat actions, and control the program’s flow based on specific conditions.

Python has three types of control structures:

  1. Sequential: Default mode
  2. Selection: Used for decisions and branching
  3. Repetition: Used for looping, i.e., repeating a code multiple times.

for more details, see Understanding Control Structures in Python

Flow control statements in Python

5.2 Conditional Statements (if, else, elif)

5.3 Looping Statements (for, while)

  • There are two ways to create loops in Python: with the for-loop and the while-loop.
  • Repeat actions using for and while loops.

5.3.1 for loop

5.3.2 while loop

5.4 Loop Control Statements (break, continue, pass)

5.5 The else Clauses on Loops

5.6 Match Statement (Python 3.10+)

Practice & Progress

Multiple-Choice Questions (MCQs)


Find and Fix Mistakes

âś… Online Quizzes for Python Control Flow Statements


Coding Exercises


Mini Projects


Review Questions


References and Bibliography

  • [1] In Python, an iterable object is an object that you can loop over using a “for” loop. It’s any object that can return its elements one at a time.
  • [2] “ForLoop - Python Wiki,” Python.org, 2017. https://wiki.python.org/moin/ForLoop
  • [3] “4. More Control Flow Tools — Python 3.13.2 documentation,” docs.python.org. https://docs.python.org/3/tutorial/controlflow.html ‌