Python Control Flow Statements

A control flow in a programming language is a block of code that analyse order of execution and chooses a control in which to go based on given arguments (values and logic). In simple sentence, a control flow is just a decision that the system makes. Without Control Flow, a source code is simply a list of statements.

Control flow of a programming language is accomplish with three basic set of control structures:

  1. Sequential
  2. Selection
  3. Iteration


Sequential statements are always execute the same sequence of commands and it will always output the same results.


Selection statements, often referred to as if...else statements that permit the developer to execute certain section of code depending on some Boolean condition.

  1. if statements
  2. if....else statements
  3. if..elif..else statements
  4. nested if statements
Python example
Python if statements


Repetition in Python used for looping, i.e. repeatedly perform some code block.

  1. while loop
  2. do..while loop
  3. for loop
Python example
python loop statements
More on.... Python control structures