DS 1501 · Lesson 5 of 24
Instructor: CS5056m
Sign in to watchModel multi-criteria real-world decision trees cleanly: slab pricing, menu systems, grading rubrics, and input validation with nested and compound conditionals. What you will learn: • Designing hierarchical decision trees with nested if/else statements. • Guard clauses to reject invalid edge cases (negative units, out-of-range grades) early. • Slab-based tariff & progressive discount computations (electricity bills, taxi fares, tiered scholarships). • Boolean flags (is_eligible = False) and conditional expressions (status = 'Pass' if score >= 55 else 'Fail'). • Avoiding dangling-else confusion and unreachable elif branches. University Outline Mapping: Class 5 · CO1 · Reading: 2.7, 3.5, 3.6 (Deitel), Chapter 5 (crash) · Activities: Lecture, Slides, Demonstration.
Note
Outline: Class 05 | CO1 | Reading: Deitel 2.7, 3.5, 3.6 & Crash Course Ch. 5 Pattern — Progressive Slab Billing (avoid double counting!): if units <= 50: bill = units * 3.5 elif units <= 150: bill = 50 * 3.5 + (units - 50) * 5.0 else: bill = 50 * 3.5 + 100 * 5.0 + (units - 150) * 6.5 Exam Trap: Always verify boundary values (e.g., exact 50 and 150) and compare <= vs <.
Same resources as in the community course — sign in to watch the lesson and track progress.
Watch the whole course.
Sign in to play every lesson, track your progress, and ask questions alongside the community.
Already signed in? Open lesson in Community