MASTER YOUR LOGIC BUILDING:Phase 1 - Level 5: Creative / Tricky Logical Scenarios

Mastering phase 1 - level 5: creative / tricky logical scenarios concepts and implementation.

Phase 1 - Level 5: Creative / Tricky Logical Scenarios

Why This Matters

Real problems rarely say "write an if statement." They say things like: "Where does this point fall on a graph?" or "Do these three numbers form a right triangle?" You have to translate a story into logic — and that's the skill that separates beginners from confident programmers.

This level is your first taste of that. The problems look tricky, but each one breaks down into simple steps you already know.

What You'll Learn

  • How to handle special cases before general ones
  • How to work with coordinates (x, y points on a graph)
  • How to check mathematical relationships with conditions
  • A reliable problem-solving process for "scary" problems

Your Problem-Solving Recipe

Every tricky problem follows the same pattern:

  1. Read carefully — what are the inputs? What should the output be?
  2. List special cases first — origin, axes, zero, equal values
  3. Handle special cases — usually with if / elif at the top
  4. Handle the general case — the "normal" logic
  5. Test — try edge inputs: 0, negative numbers, equal values
"First think in plain English. Then write one condition at a time."

Example: Where Is a Point on a Graph?

Given coordinates (x, y), you might need to find the quadrant — or notice the point sits on an axis or at the origin.

Step-by-step thinking:

  1. Is x = 0 and y = 0? → Origin
  2. Is x = 0? → On the Y-axis
  3. Is y = 0? → On the X-axis
  4. Both positive? → Quadrant I
  5. x negative, y positive? → Quadrant II
  6. Both negative? → Quadrant III
  7. Otherwise → Quadrant IV
if x == 0 and y == 0:
    print("Origin")
elif x == 0:
    print("On Y-axis")
elif y == 0:
    print("On X-axis")
elif x > 0 and y > 0:
    print("Quadrant I")
# ... and so on

Key insight: Check the weird cases (origin, axes) before the quadrants.

Example: Pythagorean Triplet

Three numbers (a, b, c) form a Pythagorean triplet if a² + b² = c² — but you don't know which number is the longest side (hypotenuse).

Step-by-step thinking:

  1. Try a² + b² = c²
  2. Also try b² + c² = a²
  3. Also try a² + c² = b²
  4. If any of these is true → it's a triplet
is_triplet = (
    (a*a + b*b == c*c) or
    (b*b + c*c == a*a) or
    (a*a + c*c == b*b)
)

Use or because only one arrangement needs to work.

Common Mistakes

  • Jumping to the general case — forgetting origin (0,0) or axis points
  • Assuming which side is the hypotenuse — always check all three arrangements
  • Trying to write everything in one giant `if` — break it into steps
  • Not testing edge cases — always try 0, negatives, and equal values

Tips

  • Draw a picture for geometry problems — even a rough sketch helps
  • Write comments for each case in plain English before coding
  • If stuck, solve one small piece first (e.g., just detect the origin)
  • It's okay if your first attempt isn't perfect — refactor step by step

Practice Focus

Tackle the examples below using the recipe above:

  • Quadrant detection — special cases first, then quadrants
  • Pythagorean triplet — check all three side arrangements with or
  • Time yourself thinking in English before typing any code

Hands-on Examples

Determine Quadrant

# Take coordinates
x = float(input("Enter x coordinate: "))
y = float(input("Enter y coordinate: "))

# Determine quadrant or axis
if x == 0 and y == 0:
    print("Origin")
elif x == 0:
    print("On Y-axis")
elif y == 0:
    print("On X-axis")
elif x > 0 and y > 0:
    print("Quadrant I")
elif x < 0 and y > 0:
    print("Quadrant II")
elif x < 0 and y < 0:
    print("Quadrant III")
else:
    print("Quadrant IV")

Check for special cases first (origin, axes), then check sign combinations for quadrants.