Operators and Decision Making Python practice problems
Translate everyday rules into comparisons, Boolean expressions, and if/elif/else branches.
Core concepts
Problem-solving patterns
- Translate each rule into one Boolean condition
Reported company tags
All 20 problems in this topic
Work from top to bottom to build the concept gradually.
- #021Classify even or odd: Locker assignmentBeginnerPremium
Classify a locker number into the even or odd row.
- #022Classify even or odd: Negative integerBeginnerPremium
Confirm that the same parity rule works for a negative number.
- #023Classify a number's sign: Profit indicatorBeginnerPremium
Classify a positive daily profit value.
- #024Classify a number's sign: Break-even dayBeginnerPremium
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 dataBeginnerPremium
Protect the report from a score outside the permitted range.
- #033Set an age-based ticket price: Child visitorBeginnerPremium
Quote the museum price for a school-age visitor.
- #034Set an age-based ticket price: Senior visitorBeginnerPremium
Apply the senior price for an older visitor.
- #035Validate and classify a triangle: Equal-sided frameBeginnerPremium
Classify a triangular frame with three equal sides.
- #036Validate and classify a triangle: Impossible frameBeginnerPremium
Reject dimensions where two sides cannot reach across the third.
- #037Check a basic password policy: Accepted signupBeginnerPremium
Validate a signup password that mixes letters and digits.
- #038Check a basic password policy: Missing digitBeginnerPremium
Reject a long password that contains no digit.
- #039Calculate a shipping fee: Large guest orderBeginnerPremium
Determine shipping for a guest whose order reaches the free-shipping threshold.
- #040Calculate a shipping fee: Small member orderBeginnerPremium
Apply the membership benefit to a small order.