Python practice: Decision Trees with if, elif, and else

Chapter 6 · 8 questions · included in full access

  1. Question 1 · easy

    Simple if branch

    Given units = 15, write an if units >= 10: statement that prints "Bulk discount applied":

    Solve it in your browser
  2. Question 2 · easy

    Two-way if and else

    Given balance = 150 and cost = 200, if balance >= cost print "Approved", else print "Declined":

    Solve it in your browser
  3. Question 3 · easy

    Tiered pricing with elif

    Given amount = 8500, assign discount: 0.20 if amount >= 10000, 0.10 if amount >= 5000, else 0.0. Print discount:

    Solve it in your browser
  4. Question 4 · easy

    Performance grading order

    Given score = 92, if score >= 90 print "Grade A", elif score >= 75 print "Grade B", else print "Grade C":

    Solve it in your browser
  5. Question 5 · medium

    Nested permission check

    Given is_logged_in = True and is_admin = True, if logged in check if admin and print "Admin Access", else print "Access Denied":

    Solve it in your browser
  6. Question 6 · easy

    Ternary inline conditional

    Given units = 15, use ternary status = "Bulk" if units >= 10 else "Standard" and print status:

    Solve it in your browser
  7. Question 7 · easy

    SLA breach notification

    Given hours_open = 48, if hours_open > 24 print "Escalate: SLA Breached!", else print "SLA Compliant":

    Solve it in your browser
  8. Question 8 · medium

    Tax bracket selector

    Given income = 800000, assign rate = 0.20 if income > 1000000, 0.10 if income > 500000, else 0.0. Print rate:

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing