AtomLearn
DashboardGoalsGraphAchievementsReviewSign In
Programming FundamentalsNot Started

Conditionals

Make decisions with if/elif/else

0%

Knowledge Debt detected

You can study this freely — but your score may plateau if these foundations have gaps. The Mastery badge requires them to be solid.

Explanation

Conditionals let your program make decisions.

python
age = 18
if age >= 18:
    print("Adult")
elif age >= 13:
    print("Teenager")
else:
    print("Child")

Comparison operators: ==, !=, >, <, >=, <= Logical operators: and, or, not

Python uses indentation (4 spaces) to define blocks — there are no curly braces.

Examples

Ternary / conditional expression

Python's one-line conditional expression

score = 75
result = "pass" if score >= 60 else "fail"
print(result)  # pass

Next in Programming Fundamentals

Scope & Namespaces

Continue

Unlocks