DataLens

NumPy Project: Toko Kita's pricing and planning

Three graded tasks with arrays and no loops. Price a promotion on every order line at once, compare three stores month by month with axes and broadcasting, and simulate a year of demand to see how often a product would run out.

Track project

Open the project

A realistic brief and graded tasks that use the whole track. Included with Pro.

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

#TaskMain skills
1Vectorised pricing rulesElement-wise maths, np.select, np.where, rounding
2Three stores, six months2D arrays, axis, broadcasting, boolean masks
3Will 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.

Open the project

A realistic brief and graded tasks that use the whole track. Included with Pro.