PYTHON Tutorial
Control flow refers to the order in which statements in a Python program are executed. It allows you to alter the flow of execution based on conditions or loops.
if condition:
# Code to execute if condition is true
for element in sequence:
# Code to execute for each element
while condition:
# Code to execute while condition is true
# Check if a number is greater than 5
if number > 5:
print("Number is greater than 5")
# Loop through a list of numbers
for number in [1, 2, 3, 4, 5]:
print(number)
# Continue looping while number is less than 10
while number < 10:
number += 1
print(number)