Python · Level 1 Logic

Control Flow

Direct program execution with conditional statements. Build decision trees using boolean logic.

  • if / elif / else chains
  • Boolean expressions
  • Logical operators: and, or, not

Use if / elif / else to branch execution. Conditions are any expression that evaluates to True or False.

score = 72

if score >= 90:
    grade = "A"
elif score >= 70:
    grade = "B"       # <- this branch runs
else:
    grade = "C"

# Logical operators
if score > 60 and score < 80:
    print("Passing")

Implement fizz_buzz(n). Return "Fizz" if n % 3 == 0, "Buzz" if n % 5 == 0, "FizzBuzz" if both, otherwise return n as a string.

solution.py
Test Suites Pending
Stdout