← Back to Blog

IF Mini Project — PACE, Your First Real Decision System

The problem...

You've learned if, elif, and else. You know the syntax. You've seen the examples.

But examples in articles are safe. Controlled. The variable is already set, the output is already known.

Time to build something real.

The idea!

In military communications, there's a protocol called PACE.

Primary. Alternate. Contingency. Emergency.

When the primary channel fails, you drop to the alternate. If that fails too, contingency. Last resort — emergency. You always have a plan. You never go silent.

Sound familiar? That's exactly how if / elif / else works.

Back to input()

Your program asks the user for the signal strength.

signal_strength = int(input("Enter signal strength (0-100): "))

int() converts what the user types into a number — otherwise Python treats it as text and the comparisons won't work.

Your mission

Build a PACE communications system. The user enters a signal strength between 0 and 100. Your program decides which protocol to activate.

  • 75 and above — Primary — radio communication
  • 50 and above — Alternate — satellite link
  • 25 and above — Contingency — field messenger
  • Below 25 — Emergency — runner dispatched

The solution

signal_strength = int(input("Enter signal strength (0-100): "))

if signal_strength >= 75:
    print("PRIMARY active — radio communication.")
elif signal_strength >= 50:
    print("ALTERNATE active — satellite link.")
elif signal_strength >= 25:
    print("CONTINGENCY active — field messenger.")
else:
    print("EMERGENCY — runner dispatched.")

Test it

# Enter: 80  -->  PRIMARY active — radio communication.
# Enter: 55  -->  ALTERNATE active — satellite link.
# Enter: 30  -->  CONTINGENCY active — field messenger.
# Enter: 10  -->  EMERGENCY — runner dispatched.

Four inputs. Four different paths. One clean decision system.

What's really happening

Python reads the number, then walks down your conditions one by one. The first one that matches — that block runs. The rest are never touched.

That's not just code. That's a decision engine.

Go further

Try these on your own:

  • Enter 75 exactly — which protocol activates? Why?
  • Change the thresholds — what happens if Primary starts at 80?
  • Add a message that also prints the signal strength: "ALTERNATE active — signal at 55."

What you should understand now

  • input() reads from the user — int() converts it to a number
  • if / elif / else builds real decision systems, not just toy examples
  • Python checks conditions top to bottom — first match wins
  • Every case is covered — your program never goes silent
[ login to bookmark ] // copied! 35 views · 2 min
// resources
Exercise pace_communications.py
← prev Split the decision. Again. next → IF Mini Project — Your ticket, your price
// 0 comments
// No comments yet. Be the first.
// leave a comment

// Your comment will appear after approval.