Level 32 of 50
Dict & set comprehensions
explained with mango prices. Watch the reel, then work through it below: run the code, take the quiz, keep the cheat sheet.
📒 Open the cheat sheetSanaEvery mango at this stall is Rs 350 a kilo!
TeacherA price for every mango? Build the dictionary in one line!
mango.py
mangoes = ["Chaunsa", "Sindhri"] rate = {m: 350 for m in mangoes} print(rate)
TeacherSame trick, curly brackets! Key, colon, value, then the loop!
SanaWhy the colon in there?
TeacherColon means key AND value. That makes a dictionary!
cities.py
cities = ["Lahore", "Quetta", "Multan"] lens = {len(c) for c in cities} print(lens)
TeacherNo colon? You get a set! All 3 have 6 letters, so just one 6!
⏸ Pause & predict: what prints?
nums = [3, 6, 9, 10] r = {n % 3 for n in nums} print(r)
Where this leads
Python is step one. Building AI that ships is the rest.
The diploma takes you from zero to deployed computer vision, LLM and agent projects, with engineers who build them for a living. Already code? The bootcamp does it in three months.