Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Control Flow – If Statements | Python Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. Python Fundamentals

Lesson 6 of 55

·Python

Control Flow – If Statements

20 minutes

Course progress11%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • `if` starts a conditional block.
  • `elif` adds additional branches.
  • `else` handles the fallback case.
  • Indentation defines the scope of each block.

Control Flow – If Statements

Conditional statements let your program choose different paths based on runtime data. Python uses if, elif, and else blocks, each terminated by a colon and an indented body.

temperature = 23
if temperature > 30:
    print("It's hot!")
elif temperature > 20:
    print("Nice weather")
else:
    print("It's cold")

Remember that Python enforces indentation (typically 4 spaces) to define code blocks – no braces needed!

Make it stickPractice what you've learned1 quiz · 5 practical tests · Optional activities from Python FundamentalsBrowse activities
Previous lessonBasic OperatorsContinue to lesson 7Loops – WhileBack to Python Fundamentals curriculum