Python for Beginners
Guided lesson · 9 minutes

3. Make decisions with conditions

Work through the guide, keep private notes, and mark this lesson complete when you’re ready.

01

Choose between paths

An if statement runs code only when a condition is true. For example, if score >= 70: can choose a passing message. Use elif for another condition and else for the remaining case.

02

Make conditions precise

Comparison operators include == for equality, != for difference, and < or > for numeric comparison. A single equals sign assigns a value; two equals signs compare values. Indentation shows which instructions belong to each branch.

03

Try it

Write a condition that prints Eligible when a number is at least 18 and Not yet otherwise. Try values on both sides of the boundary, including 18.

Key takeaways

  • Conditions let a program choose a path.
  • Use == to compare values and = to assign.
  • Check boundary values as well as typical values.
Enroll in this course to save lesson progress.View course