pyPython Practice LabFrom first print to final round
TOPIC 03 OF 18

Decisions with Conditions Python practice problems

if, elif, else, truth values, validation, and choosing between outcomes.

20 exercises8+ conceptsBeginner → interview context
Start this topic
WHAT YOU WILL PRACTISE

Core concepts

Classify even or oddClassify a number's signFind the larger of two valuesFind the largest of three valuesDetect a leap yearConvert a score to a gradeSet an age-based ticket priceValidate and classify a triangle
REUSABLE THINKING

Problem-solving patterns

  • if · modulo
  • comparison · elif
  • comparison · branches
  • max · list
  • boolean logic · calendar
PRACTICE OUTCOME

What this topic builds

Learn the idea once, use it across the exercises, and explain why your approach works.

ORDERED PRACTICE

All 20 problems in this topic

Work from top to bottom to build the concept gradually.

  1. #021
    Classify even or odd: Locker assignment

    Classify a locker number into the even or odd row.

    StarterPremium
  2. #022
    Classify even or odd: Negative integer

    Confirm that the same parity rule works for a negative number.

    StarterPremium
  3. #023
    Classify a number's sign: Profit indicator

    Classify a positive daily profit value.

    StarterPremium
  4. #024
    Classify a number's sign: Break-even day

    Classify a day with no profit or loss.

    StarterPremium
  5. #025
    Find the larger of two values: Compare two bids

    Choose the larger of two supplier bids for a comparison report.

    BeginnerPremium
  6. #026
    Find the larger of two values: Equal readings

    Report equality when two sensors return the same value.

    BeginnerPremium
  7. #027
    Find the largest of three values: Highest test score

    Find the highest score among three finalists.

    BeginnerPremium
  8. #028
    Find the largest of three values: All negative temperatures

    Find the least cold value when every temperature is negative.

    BeginnerPremium
  9. #029
    Detect a leap year: Modern leap year

    Determine whether a scheduling year includes February 29.

    BeginnerPremium
  10. #030
    Detect a leap year: Century exception

    Check a century year that is divisible by 100 but not by 400.

    BeginnerPremium
  11. #031
    Convert a score to a grade: Passing grade

    Convert a valid assessment score to its letter grade.

    BeginnerPremium
  12. #032
    Convert a score to a grade: Reject bad data

    Protect the report from a score outside the permitted range.

    IntermediatePremium
  13. #033
    Set an age-based ticket price: Child visitor

    Quote the museum price for a school-age visitor.

    IntermediatePremium
  14. #034
    Set an age-based ticket price: Senior visitor

    Apply the senior price for an older visitor.

    IntermediatePremium
  15. #035
    Validate and classify a triangle: Equal-sided frame

    Classify a triangular frame with three equal sides.

    IntermediatePremium
  16. #036
    Validate and classify a triangle: Impossible frame

    Reject dimensions where two sides cannot reach across the third.

    IntermediatePremium
  17. #037
    Check a basic password policy: Accepted signup

    Validate a signup password that mixes letters and digits.

    IntermediatePremium
  18. #038
    Check a basic password policy: Missing digit

    Reject a long password that contains no digit.

    AdvancedPremium
  19. #039
    Calculate a shipping fee: Large guest order

    Determine shipping for a guest whose order reaches the free-shipping threshold.

    AdvancedPremium
  20. #040
    Calculate a shipping fee: Small member order

    Apply the membership benefit to a small order.

    AdvancedPremium