Control Flow in Python with Conditional Statements

Control Flow in Python with Conditional Statements

Programs can be written to follow a particular way satisfying some conditions specified. This way you can control how you want your code to run. This article will help explain a control flow in Python writing one with conditional statements.

What is a Control Flow

Control flow is an order in which the program’s code executes satisfying a certain condition. If a condition is not specified the program will just go sequentially.


A Control flow is the basic decision-making process in programming and flow of control determines how a computer program will respond when given certain conditions and parameters.

  • Net Informations

A program control flow can be ordered using conditional statements(if-else-elif), for or while loops, break, continue, and pass statements. For this article, I will just cover how to write a control flow using conditional statements.

What is a Conditional statement

Conditional statements often referred to as if-else-elif statements, allow the programmer to execute certain pieces of code depending on some Boolean condition.

  • IF Statement: This statement is used to write code that gets executed under a certain condition.

  • ELSE Statement: the ELSE statement is used to add code you want to run when the condition of the IF statement is false.

  • ELIF Statement: the ELIF statement is used to alternative conditions to the control flow.

Now let's code a simple control flow:

score = 100
if score == 100
    print("Great Job")
elif score >= 60
    print("Not bad")

The above program was to give an output satisfying some conditions. If the score equals 100 which is true, it prints out great job. In a case where the score is greater or equals 6, it prints, not bad, else it prints invalid especially when the score input does not satisfy the conditions given.

Following this simple procedure, you can write a control flow using a conditional statement.

If this article was helpful to you, feel free to leave a comment, like, and share. Thanks for reading :)