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

Operators and Decision Making Python practice problems

Translate everyday rules into comparisons, Boolean expressions, and if/elif/else branches.

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

  • Translate each rule into one Boolean condition
INTERVIEW SIGNALS

Reported company tags

TCSWiproCognizantAmazonGoogleMicrosoft
Community-reported tags are guidance, not guarantees.
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.

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

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

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

    Classify a positive daily profit value.

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

    Classify a day with no profit or loss.

    BeginnerPremium
  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.

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

    Quote the museum price for a school-age visitor.

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

    Apply the senior price for an older visitor.

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

    Classify a triangular frame with three equal sides.

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

    Reject dimensions where two sides cannot reach across the third.

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

    Validate a signup password that mixes letters and digits.

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

    Reject a long password that contains no digit.

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

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

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

    Apply the membership benefit to a small order.

    BeginnerPremium