Q.The principal of a school wants to do following analysis on the basis of food items procured and sold in the canteen:
Create an appropriate dataset for these items (fruit juice, biscuits, samosa) by listing their purchase price and sale price. Apply basic statistical techniques to make the comparisons.
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Build a small dataset of the three items (the question asks us to create it), then match each analysis to its technique: a) purchase-vs-sale comparison → the difference (profit per item); b) comparing sales of the three items → totals/means compared item-wise (a bar chart); c) variation in same-quantity juice prices → range and standard deviation.
Step 1 — create the dataset (sample data we define ourselves)
import pandas as pd
df = pd.DataFrame({
'Item': ['Fruit Juice', 'Biscuits', 'Samosa'],
'PurchasePrice': [20, 10, 8], # rupees per unit
'SalePrice': [25, 12, 10],
'UnitsSold': [120, 200, 150] # units sold this month
})
df['Profit'] = df['SalePrice'] - df['PurchasePrice']
df['SaleValue'] = df['SalePrice'] * df['UnitsSold']
print(df)
Expected output:
| Item | PurchasePrice | SalePrice | UnitsSold | Profit | SaleValue | |
|---|---|---|---|---|---|---|
| 0 | Fruit Juice | 20 | 25 | 120 | 5 | 3000 |
| 1 | Biscuits | 10 | 12 | 200 | 2 | 2400 |
| 2 | Samosa | 8 | 10 | 150 | 2 | 1500 |
Key line: df['Profit'] = df['SalePrice'] - df['PurchasePrice'] — pandas subtracts the columns element-wise, computing every item's margin in one statement.
a) Compare purchase and sale price of fruit juice and biscuits
Technique: the difference between the two prices (the profit per unit). Fruit juice: 25 − 20 = ₹5; biscuits: 12 − 10 = ₹2. Juice earns more per unit; relative to cost, juice marks up 25% and biscuits 20%. A paired bar chart (purchase bar next to sale bar for each item) shows this at a glance.
b) Compare sales of fruit juice, biscuits and samosa
Technique: compare the totals — units sold (and/or sale value) per item, i.e., a simple item-wise aggregate comparison, drawn as a bar chart (x-axis: item; y-axis: units sold). From the dataset: biscuits sell the most units (200), then samosa (150), then juice (120); by revenue, juice leads (₹3000) because of its higher price. Comparing both columns tells the principal what sells most vs what earns most.
c) Variation in sale price of fruit juices of different companies (same quantity)
Take the sale prices of five companies' 200 ml juice packs and apply the measures of variation — range and standard deviation:
import statistics …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.