SyntaxStudy
Sign Up
Python Beginner 10 min read

Control Flow

Control Flow in Python

Control flow determines the order of code execution.

if / elif / else

score = 85
if score >= 90:
    print("A")
elif score >= 80:
    print("B")
else:
    print("C")

for Loop

for i in range(5):
    print(i)

while Loop

count = 0
while count < 3:
    print(count)
    count += 1

break / continue

for i in range(10):
    if i == 5: break
    if i % 2 == 0: continue
    print(i)
Pro Tip

Use range(start, stop, step) to control loop ranges precisely.