Lab · Python Programming
Lab: a chai stall's day in numbers
The brief
Raju runs a chai stall near a bus stand. Use variables and Python maths to work out his sales, his profit, how he banks the cash and his profit margin.
Why it matters
Every small shop owner asks the same questions at closing time: how much came in, how much is profit, and how much cash goes to the bank. This is the same maths an accountant or a billing app does, written as a program you can rerun every day.
Skills you practise
- variables
- arithmetic operators
- floor division and remainder
- round()
- print()
What you will have at the end
stall.py: a short program that turns a day's sales figures into sales, profit, cash to bank and margin, and prints each one.
How it is marked (rubric, 100 points)
| Correct numbersAll four checks pass: sales 2850, profit 1520, 3 notes and 20 change, margin 53.3. | 50 |
|---|---|
| Uses variables, not typed-in numbersEvery calculation uses the names from data.py, so it still works when the numbers change. | 25 |
| Right operator for the job// and % for notes and change, / and round() for the margin. | 15 |
| Clear outputEach result is printed with a label, so Raju can read it. | 10 |
0/4 steps done
Step 1 of 4
Money taken today
sales holds the money taken today: chai sales plus samosa sales (2850 rupees).
data.py runs before your file, so its variables are ready to use. Sales from one item are price × quantity. Add the chai sales and the samosa sales and store the answer in a variable called sales.
Use the variable names, not the numbers. Then the same program still works tomorrow when the numbers change.
Run shows what your code prints. Check runs the step's tests. Ctrl+Enter checks too.