Python
Making decisions
A practical reference with examples you can run.
Introduction
A conditional chooses an action based on a true-or-false expression. Think about the boundary: does a score of exactly 10 belong in the first branch? Test values below, at, and above that boundary.
Syntax & example
score = 12
if score >= 10:
print("Ready for the next step!")
else:
print("Keep practicing!")Expected output
Ready for the next step!
Common mistakes
- Using a variable before assigning a value to it.
- Mixing text and numbers without converting deliberately.
- Skipping an empty input or a boundary value when testing.
Practice
Change the score and test both branches.
main.pyYour ideas, in code.
Loading your editor…
Run your code to see the output here.
Ready to buildUTF-85 lines