The brief
Toko Kita is a small Indonesian online shop that sells coffee, kitchen equipment, stationery, home goods and a few electronics. It has also opened pick-up counters in three cities. The planning team does its sums in spreadsheets, and the spreadsheets have started to crawl. They've asked you to rebuild three of their calculations with NumPy.
The rule for this project is the same as for the whole track: no Python loops over the data. The point of NumPy is that one expression works on every element at once, which is both faster and shorter than a loop, and the checks look for loops. If you catch yourself writing for, there's an array method or a boolean mask that does the same job.
How the tasks work
Each task is checked automatically, like the module questions. The tickets give you the data and the exact names of the results, but not which functions to use. There are hints if you get stuck, but try each one without opening the solution first. Remember to give integer arrays an explicit dtype=np.int64 where a task asks for whole numbers, so the results are the same on every computer.
The tasks
| # | Task | Main skills |
|---|---|---|
| 1 | Vectorised pricing rules | Element-wise maths, np.select, np.where, rounding |
| 2 | Three stores, six months | 2D arrays, axis, broadcasting, boolean masks |
| 3 | Will we run out? | Seeded random numbers, comparisons, averages of masks |
Every task gives you its data in the starter code, so there's no file to load. When you're ready, open Task 1.