By the end of this lab, you will be able to:
- Create and manipulate Python dictionaries
- Access, add, and modify dictionary values
- Create a list of dictionaries
- Loop through dictionaries to display data
| Activity | Duration |
|---|---|
| 🎯 Lecture & Slides | 30 min |
| 📖 Tutorial Notebook | 60 min |
| ☕ Break | 15 min |
| ✍️ Exercise Notebook | 45 min |
| 📤 Submit & Auto-grade | 15 min |
| 💬 Q&A | 15 min |
template-lab01-dictionary/
├── README.md # This file
├── slides/
│ └── Lab01_Slides.tex # Lecture slides (LaTeX Beamer)
├── tutorial/
│ └── Lab01_Tutorial.ipynb # Learn step-by-step
├── exercise/
│ └── Lab01_Exercise.ipynb # Complete the exercises
├── data/
│ └── diseases.md # Sample disease data
└── tests/
└── test_lab01.py # Auto-grading tests
Start with tutorial/Lab01_Tutorial.ipynb to learn the concepts.
After finishing the tutorial, open exercise/Lab01_Exercise.ipynb and complete all 5 exercises.
git add .
git commit -m "Complete Lab 01"
git pushGo to the Actions tab in your GitHub repository to see your auto-grading results.
A dictionary stores data as key-value pairs, like a real dictionary where:
- Key = the word you look up
- Value = the definition
# Example: Disease information
disease = {
"name": "Rubella", # key: "name", value: "Rubella"
"symptoms": "fever, rash", # key: "symptoms", value: "fever, rash"
"treatment": "rest" # key: "treatment", value: "rest"
}In RAG (Retrieval-Augmented Generation) systems, we store documents as dictionaries:
- Easy to organize metadata
- Fast lookup by key
- Flexible structure for different document types
| Exercise | Points |
|---|---|
| Exercise 1: Create a dictionary | 20 |
| Exercise 2: Add a new key | 20 |
| Exercise 3: Access values | 20 |
| Exercise 4: Create list of dictionaries | 20 |
| Exercise 5: Loop through data | 20 |
| Total | 100 |
- Read the tutorial carefully before starting exercises
- Test your code by running each cell
- Check the expected output format
- Don't hesitate to ask for help!
- Python Dictionary Documentation
- Disease data from: Generic-RAG/md_corpus/
Course: CSI403 - Full Stack Program Development
Lab: 01 - Python Dictionary