Net-informations.com

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

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

Selection

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

Iteration

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










net-informations.com (C) 2021    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About