April 29, 2026

Lists, Tuples & Dictionaries in Python (Patient Records, Drug Data & Dose Lists)

Lists, Tuples & Dictionaries in Python for Pharmacy Students (Patient Records, Drug Data & Dose Management)

Data structures in Python are used to store and organize data efficiently. In pharmaceutical sciences, they are essential for handling patient records, drug information, and dosage data.


๐Ÿ”ท What are Data Structures?

Data structures allow storing multiple values in a single variable.

๐Ÿ’ก Key Insight: Data structures are like organized storage systems used in hospitals and pharmacies.

๐Ÿ”ท Lists (Mutable Data Structure)

A list is used to store multiple values in a single variable. Lists are mutable, meaning they can be changed.

doses = [500, 650, 400]
print(doses)

๐Ÿ’Š Pharma Example

patient_doses = [500, 500, 650, 400]
print("Dose list:", patient_doses)

Used for storing multiple patient doses.


๐Ÿ”ท Tuples (Immutable Data Structure)

A tuple is similar to a list but cannot be changed once created.

drug_info = ("Paracetamol", 500, "Tablet")

๐Ÿ’Š Pharma Example

Used for fixed drug properties like composition.


๐Ÿ”ท Dictionaries (Key-Value Pair)

A dictionary stores data in key-value pairs.

patient = {
    "name": "John",
    "age": 45,
    "drug": "Aspirin"
}

๐Ÿ’Š Pharma Example

Represents patient records in clinical settings.


๐Ÿ”ท Difference Between List, Tuple & Dictionary

FeatureListTupleDictionary
MutableYesNoYes
StructureOrderedOrderedKey-Value
Example[500, 650](500, 650){“dose”:500}

๐Ÿง  Memory Trick

  • List โ†’ Changeable (Multiple doses)
  • Tuple โ†’ Fixed (Drug properties)
  • Dictionary โ†’ Patient record (Key-Value)

๐Ÿงช Practice Exercise

Create:

  • List of 5 patient doses
  • Tuple for drug information
  • Dictionary for patient record

๐Ÿงช Mini Project

Create a simple patient data system:

patient = {
    "name": "Alice",
    "age": 30,
    "dose": [500, 650]
}

print(patient)

๐Ÿ“ MCQs

  1. Which data structure is mutable?
    a) Tuple
    b) List
    c) String
    d) None
    Answer: b

  2. Which is immutable?
    a) List
    b) Dictionary
    c) Tuple
    d) Set
    Answer: c

  3. Dictionary stores data as:
    a) List
    b) Tuple
    c) Key-Value
    d) Array
    Answer: c

โ“ FAQs

Why are data structures important in pharmacy?

They help in organizing patient data, drug records, and dosage information efficiently.

When should we use tuple?

When data should not be changed, such as drug composition.


๐Ÿ“ฅ Download Pharma Data Practice Exercises

Includes patient datasets and coding problems.


โžก Next Topic: Indexing & Slicing in Python โ†’

Recommemded readings

  1. Lists, Tuples & Dictionaries (with pharma data examples) : Current page
  2. Indexing, Slicing & Operations (Extracting patient/drug data)
  3. NumPy Arrays (Dose calculations, concentration arrays)
  4. CSV File Handling (Reading ADR datasets, writing reports)
  5. Understanding Healthcare Datasets (Structure, columns, patient data interpretation)
  6. Data Access & Manipulation (Filter, select, basic operations)

Question Bank Unit 3: Data Structures & File Handling

For more details: Basics of Python Programming for Pharmaceutical Sciences