Member-only story

Python 101 — Control Flow, if/else

Adina Socaci
5 min readNov 19, 2023

--

There are situations in real life when we need to make some decisions and based on these decisions, we decide what we should do next. 🤔

Similar situations arise in programming also where we need to make some decisions and based on these decisions we will execute the next block of code. Control Flow is basically a block of conditional statements in Python languages which decide the direction of the flow of program execution.

if statement

The if statement is a fundamental control flow statement in programming languages, including Python. It allows you to make decisions based on specific conditions, altering the program’s execution path accordingly. The basic structure of an if statement involves a condition and a block of code to be executed if the condition evaluates to true.

if condition:
# Code block to execute if condition is true

The condition is an expression that evaluates to either True or False. If the condition evaluates to True, the code block following the if statement is executed. If the condition evaluates to False, the code block is skipped, and the program proceeds to the next statement.

--

--

Adina Socaci
Adina Socaci

Written by Adina Socaci

Tech | Science | Languages | Having Fun

No responses yet