Every chef keeps their spices within arm's reach. Quick-reference cards for the syntax and formulas you grab mid-recipe.
pin these above your station! ↓x = 42 # int price = 99.5 # float name = 'Chef' # str fresh = True # bool nothing = None # null
dish, qty = 'biryani', 3
f'{qty}x {dish}'
f'{price:.2f}' # 2 decimals
f'{qty=}' # qty=3
f'{name:>10}' # right-alignmenu = ['dal', 'naan', 'rice']
menu[0] # 'dal'
menu[-1] # 'rice'
menu[1:] # ['naan','rice']
menu[::-1] # reversed
menu.append('chai')spice = {'heat': 7, 'salt': 2}
spice['heat'] # 7
spice.get('umami', 0) # default 0
spice.items() # (key, value) pairs
spice.keys() | spice.values()doubled = [x*2 for x in nums]
hot = [s for s in spices
if s.heat > 5]
lookup = {s.name: s.heat
for s in spices}def season(dish, salt=1):
return f'{dish} +{salt} salt'
season('dal') # default
season('dal', salt=3) # keyword
square = lambda x: x*xfor i, item in enumerate(menu):
...
for a, b in zip(list1, list2):
...
for k, v in spice.items():
...Truthiness: empty things ([], "", {}, 0, None) are False. Write "if menu:" not "if len(menu) > 0:".
| Call | Returns | Example |
| sorted(xs, key=...) | new sorted list | sorted(dishes, key=lambda d: d.price) |
| enumerate(xs, 1) | (index, item) pairs | numbered menu from 1 |
| zip(a, b) | paired tuples | names with prices |
| any(...) / all(...) | bool | any(s.heat > 8 for s in spices) |
| range(start, stop, step) | lazy int sequence | range(10, 0, -2) |
FIG C.1: Python Essentials — 10 CARDS · TAPE TO STATION WALL