April 24, 2026

Nested Conditional Statements (Complex Clinical Decision Trees)

Nested Conditional Statements in Python for Pharmacy Students (Clinical Decision Trees & Dose Optimization)

Nested conditional statements allow one if condition inside another. In pharmaceutical sciences, they are essential for handling complex clinical decisions involving multiple patient parameters.


๐Ÿ”ท What are Nested Conditional Statements?

A nested condition means placing an if statement inside another if or else block.

if condition1:
    if condition2:
        statement
๐Ÿ’ก Key Insight: Nested conditions simulate real-life clinical decision trees.

๐Ÿ”ท Basic Example

age = 65
kidney_issue = True

if age > 60:
    if kidney_issue:
        print("Reduce dose significantly")

๐Ÿ’Š Clinical Decision Tree Example

age = 70
kidney_issue = True
liver_issue = False

if age > 60:
    if kidney_issue:
        print("Reduce dose by 50%")
    elif liver_issue:
        print("Monitor liver function")
    else:
        print("Slight dose reduction")
else:
    print("Standard dose")

This structure mimics how clinicians evaluate multiple patient factors before prescribing.


๐Ÿ’Š Toxicity + Dose Decision

concentration = 12
age = 65

if concentration > 10:
    if age > 60:
        print("High toxicity risk โ€“ reduce dose immediately")
    else:
        print("Moderate toxicity โ€“ monitor patient")
else:
    print("Safe concentration")

๐Ÿ”ท Multi-Level Nested Condition

temperature = 104
bp = 150

if temperature > 100:
    if bp > 140:
        print("Emergency condition")
    else:
        print("Fever only")
else:
    print("Normal condition")

๐Ÿง  Memory Trick

  • Outer if โ†’ Main decision
  • Inner if โ†’ Detailed check
  • Think: Step-by-step clinical evaluation

๐Ÿงช Practice Exercise

Create a program that:

  • Takes patient age and toxicity level
  • Gives dose adjustment recommendation

๐Ÿ“ MCQs

  1. Nested condition means:
    a) Loop inside loop
    b) If inside if
    c) Function inside loop
    d) Variable inside function
    Answer: b

  2. Which is true about nested conditions?
    a) Only one condition allowed
    b) Multiple levels possible
    c) Cannot use else
    d) Only numeric values
    Answer: b

  3. Nested conditions are useful for:
    a) Simple printing
    b) Complex decisions
    c) Looping
    d) Input
    Answer: b

โ“ FAQs

Why use nested conditions?

They allow handling multiple conditions step-by-step, similar to clinical decision-making.

Are nested conditions difficult?

They are easy if visualized as decision trees.


๐Ÿ“ฅ Download Clinical Decision Tree Exercises

Includes real patient-based scenarios.


โžก Next Topic: Loops in Python (for & while) โ†’

Unit 2 Blog:

Question Bank Unit 2: Control Structures & Functions

For more details: Basics of Python Programming for Pharmaceutical Sciences