Back to teaching portfolio

Chapter 3 · Decision Structures

CSBP119 Practical Questions

Conditionals give console programs their personality. These challenges focus on Boolean logic, branching, and user messaging so students see why if/elif/else blocks matter.

Problem 1 · Safety Gate

Equipment Loan Eligibility

Determine if a student may check out lab equipment. Requirements: GPA ≥ 2.5, completed safety training, and no outstanding fees.

  1. Read GPA (float), training status (y/n), and outstanding fee amount.
  2. Use Boolean operators to evaluate the rule.
  3. Print “Approved” or “Denied” plus a reason.
gpa = float(input("GPA: "))
trained = input("Safety training completed (y/n): ").strip().lower() == 'y'
fees = float(input("Outstanding fees (AED): "))

eligible = gpa >= 2.5 and trained and fees == 0

if eligible:
    print("Loan approved – enjoy the equipment!")
else:
    print("Loan denied. Please verify GPA, training, and fee status.")
Problem 2 · Parking

Campus Parking Pass Recommender

Create a decision tree that recommends a parking pass type based on commuter category and arrival time.

  1. Collect commuter type (faculty, staff, student) and arrival hour (0–23).
  2. Use nested conditionals for premium vs. standard lots.
  3. Emit the pass recommendation.
commuter = input("Commuter type (faculty/staff/student): ").strip().lower()
hour = int(input("Arrival hour (0-23): "))

if commuter == "faculty":
    ticket = "Faculty Premium"
elif commuter == "staff":
    ticket = "Staff Standard" if hour >= 10 else "Staff Priority"
else:
    ticket = "Student Evening" if hour >= 15 else "Student Standard"

print("Recommended pass:", ticket)
Problem 3 · Scholarship Review

Scholarship Eligibility Checker

Determine whether a student qualifies for a scholarship based on GPA, completed credit hours, and a service-learning flag.

  1. Accept GPA, earned credits, and a yes/no string.
  2. Use nested conditionals to enforce rules.
  3. Provide feedback with the failing requirement when rejecting.
gpa = float(input("Current GPA: "))
credits = int(input("Completed credits: "))
service = input("Finished service-learning project (y/n): ").strip().lower() == "y"

if gpa < 3.2:
    print("Not eligible: GPA below 3.2")
elif credits < 45:
    print("Not eligible: Need at least 45 credits")
elif not service:
    print("Not eligible: Service-learning project incomplete")
else:
    print("Eligible for scholarship review!")