Python practice: Decision Trees with if, elif, and else
Chapter 6 · 8 questions · included in full access
Question 1 · easy
Simple if branch
Solve it in your browserGiven
units = 15, write anif units >= 10:statement that prints"Bulk discount applied":Question 2 · easy
Two-way if and else
Solve it in your browserGiven
balance = 150andcost = 200, ifbalance >= costprint"Approved", else print"Declined":Question 3 · easy
Tiered pricing with elif
Solve it in your browserGiven
amount = 8500, assign discount:0.20ifamount >= 10000,0.10ifamount >= 5000, else0.0. Print discount:Question 4 · easy
Performance grading order
Solve it in your browserGiven
score = 92, ifscore >= 90print"Grade A", elifscore >= 75print"Grade B", else print"Grade C":Question 5 · medium
Nested permission check
Solve it in your browserGiven
is_logged_in = Trueandis_admin = True, if logged in check if admin and print"Admin Access", else print"Access Denied":Question 6 · easy
Ternary inline conditional
Solve it in your browserGiven
units = 15, use ternarystatus = "Bulk" if units >= 10 else "Standard"and printstatus:Question 7 · easy
SLA breach notification
Solve it in your browserGiven
hours_open = 48, ifhours_open > 24print"Escalate: SLA Breached!", else print"SLA Compliant":Question 8 · medium
Tax bracket selector
Solve it in your browserGiven
income = 800000, assignrate = 0.20ifincome > 1000000,0.10ifincome > 500000, else0.0. Printrate:
These questions are part of full access.
The first chapters of every track are free. Full access is a one-time payment.
See pricing