Start with shapes
Before you write a Python tool, decide what your data looks like in memory.
Most small command-line tools use only a few shapes: strings, numbers, booleans, lists, and dictionaries. If you can model your data with these, your script becomes easier to read, test, and change.
One idea
Python tools are mostly data going through steps. Pick a clear shape for the data first, then write code that transforms it.
Use the right type
Use a string for one piece of text, like a name or email. Use an int or float for numbers you may calculate with. Use a boolean for yes/no state.
Use a list when you have many similar items. Use a dictionary when each item has named fields, like a row from a CSV or a response from an API.
Model a record
Imagine your tool checks student project ideas and creates a short review. One project can be a dictionary. Many projects can be a list of dictionaries.
This is close to how JSON and APIs usually look, so it will help in later lessons.
project = {
"team": "ByteBoys",
"college": "Pune Institute of Computer Technology",
"idea": "UPI expense splitter for hostel students",
"uses_ai": True,
"score": 7
}
projects = [
project,
{
"team": "NullPointers",
"college": "SRM Chennai",
"idea": "Resume feedback bot",
"uses_ai": True,
"score": 8
}
]
print(projects[0]["idea"])
print(projects[1]["score"])Common mistake
Do not store related fields as separate lists unless you have a strong reason.
If names, ideas, and scores are in three different lists, one missing item can break the match. A list of dictionaries keeps each record together.
# Hard to maintain
teams = ["ByteBoys", "NullPointers"]
ideas = ["UPI expense splitter", "Resume feedback bot"]
scores = [7, 8]
# Better for tool data
projects = [
{"team": "ByteBoys", "idea": "UPI expense splitter", "score": 7},
{"team": "NullPointers", "idea": "Resume feedback bot", "score": 8}
]Transform the data
A tool should not only store data. It should produce something useful.
Here, the script reads in-memory project records, adds a simple label, and prints a report line. Later, the same records can come from a file or API.
projects = [
{"team": "ByteBoys", "idea": "UPI expense splitter", "uses_ai": True, "score": 7},
{"team": "NullPointers", "idea": "Resume feedback bot", "uses_ai": True, "score": 8},
{"team": "StackSeniors", "idea": "Mess menu tracker", "uses_ai": False, "score": 5}
]
for project in projects:
if project["score"] >= 7:
label = "shortlist"
else:
label = "needs work"
ai_note = "AI feature" if project["uses_ai"] else "No AI feature"
print(f'{project["team"]}: {label} - {ai_note} - {project["idea"]}')Name fields clearly
Use field names that explain the data without comments. Prefer team, idea, score, and uses_ai over t, x, n, and flag.
When you later add sample input to your GitHub repo, clear names make your project easier for mentors and recruiters to run.
Do this now
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done