Python Data Structures Recap
Before diving into ML, let us refresh the most important Python data structures: lists, dictionaries, and functions. You will use these constantly when handling data and building models.
Lists – Ordered Collections
features = ["age", "income", "score"]
print(features[0]) # age
features.append("gender")
for f in features:
print(f)Use lists for sequences of values (e.g., a row of data).Dictionaries – Key‑Value Pairs
patient = {"name": "Alice", "age": 45, "condition": "flu"}
print(patient["age"]) # 45
patient["medication"] = "paracetamol"Dictionaries are great for representing records with named fields.Functions – Reusable Code Blocks
def mean(values):
return sum(values) / len(values)
print(mean([10,20,30])) # 20.0Functions help you avoid repetition and organize your ML pipeline (e.g., a function to clean data, another to train).Why These Matter for ML
You will store features in lists, rows in dictionaries or DataFrames (next chapter), and wrap repeated tasks in functions (e.g., `preprocess()`, `train_model()`).
Two Minute Drill
- Lists: ordered, indexed by position.
- Dictionaries: key‑value pairs for labeled data.
- Functions: reusable blocks, return values.
- Master these before moving to NumPy and Pandas.
Need more clarification?
Drop us an email at career@quipoinfotech.com
