0Pricing
Python Academy · Lesson

if / elif / else Statements

Write conditional logic to branch program execution.

Introduction

Conditional statements let your program choose different execution paths based on boolean expressions.

Basic if Statement

if condition: runs the indented block when condition is truthy. Indentation (4 spaces) defines the block — no braces needed.
x = 10
if x > 0:
    print('positive')

All lessons in this course

  1. if / elif / else Statements
  2. for Loops and range()
  3. while Loops and Loop Control
  4. Nested Loops and Loop Patterns
← Back to Python Academy