Decisions with Conditions Python practice problems
if, elif, else, truth values, validation, and choosing between outcomes.
Core concepts
Problem-solving patterns
- if · modulo
- comparison · elif
- comparison · branches
- max · list
- boolean logic · calendar
What this topic builds
Learn the idea once, use it across the exercises, and explain why your approach works.
All 20 problems in this topic
Work from top to bottom to build the concept gradually.
- #021Classify even or odd: Locker assignmentStarterPremium
Classify a locker number into the even or odd row.
- #022Classify even or odd: Negative integerStarterPremium
Confirm that the same parity rule works for a negative number.
- #023Classify a number's sign: Profit indicatorStarterPremium
Classify a positive daily profit value.
- #024Classify a number's sign: Break-even dayStarterPremium
Classify a day with no profit or loss.
- #025Find the larger of two values: Compare two bidsBeginnerPremium
Choose the larger of two supplier bids for a comparison report.
- #026Find the larger of two values: Equal readingsBeginnerPremium
Report equality when two sensors return the same value.
- #027Find the largest of three values: Highest test scoreBeginnerPremium
Find the highest score among three finalists.
- #028Find the largest of three values: All negative temperaturesBeginnerPremium
Find the least cold value when every temperature is negative.
- #029Detect a leap year: Modern leap yearBeginnerPremium
Determine whether a scheduling year includes February 29.
- #030Detect a leap year: Century exceptionBeginnerPremium
Check a century year that is divisible by 100 but not by 400.
- #031Convert a score to a grade: Passing gradeBeginnerPremium
Convert a valid assessment score to its letter grade.
- #032Convert a score to a grade: Reject bad dataIntermediatePremium
Protect the report from a score outside the permitted range.
- #033Set an age-based ticket price: Child visitorIntermediatePremium
Quote the museum price for a school-age visitor.
- #034Set an age-based ticket price: Senior visitorIntermediatePremium
Apply the senior price for an older visitor.
- #035Validate and classify a triangle: Equal-sided frameIntermediatePremium
Classify a triangular frame with three equal sides.
- #036Validate and classify a triangle: Impossible frameIntermediatePremium
Reject dimensions where two sides cannot reach across the third.
- #037Check a basic password policy: Accepted signupIntermediatePremium
Validate a signup password that mixes letters and digits.
- #038Check a basic password policy: Missing digitAdvancedPremium
Reject a long password that contains no digit.
- #039Calculate a shipping fee: Large guest orderAdvancedPremium
Determine shipping for a guest whose order reaches the free-shipping threshold.
- #040Calculate a shipping fee: Small member orderAdvancedPremium
Apply the membership benefit to a small order.