Challenge: Sales and Revenue
If you want to multiply rows (or columns) by different values, the length of the vector you use must match the number of rows (or columns) in the matrix. This ensures that each row (or column) element is multiplied by the corresponding value.
Swipe to start coding
You have the selling data for a local furniture store stored in the sellings matrix:
| Month | Sofa | Armchair | Dining table | Dining chair | Bookshelf |
|---|---|---|---|---|---|
| March | 16 | 21 | 30 | 23 | 10 |
| April | 40 | 39 | 13 | 21 | 16 |
| May | 11 | 21 | 36 | 32 | 16 |
And a vector of prices named prices:
| Sofa | Armchair | Dining table | Dining chair | Bookshelf |
|---|---|---|---|---|
| 340 | 150 | 115 | 45 | 160 |
Your tasks are:
- Output the total number of items sold each month.
- Transpose the
sellingsmatrix and reassign the result to thesellingsvariable. - Find out the revenue for each good by multiplying
sellingsandprices. Save the result in theincomevariable. - Output the monthly revenues.
- Output the total three months' revenue.
Lösning
Tack för dina kommentarer!
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Fantastiskt!
Completion betyg förbättrat till 2.27
Challenge: Sales and Revenue
Svep för att visa menyn
If you want to multiply rows (or columns) by different values, the length of the vector you use must match the number of rows (or columns) in the matrix. This ensures that each row (or column) element is multiplied by the corresponding value.
Swipe to start coding
You have the selling data for a local furniture store stored in the sellings matrix:
| Month | Sofa | Armchair | Dining table | Dining chair | Bookshelf |
|---|---|---|---|---|---|
| March | 16 | 21 | 30 | 23 | 10 |
| April | 40 | 39 | 13 | 21 | 16 |
| May | 11 | 21 | 36 | 32 | 16 |
And a vector of prices named prices:
| Sofa | Armchair | Dining table | Dining chair | Bookshelf |
|---|---|---|---|---|
| 340 | 150 | 115 | 45 | 160 |
Your tasks are:
- Output the total number of items sold each month.
- Transpose the
sellingsmatrix and reassign the result to thesellingsvariable. - Find out the revenue for each good by multiplying
sellingsandprices. Save the result in theincomevariable. - Output the monthly revenues.
- Output the total three months' revenue.
Lösning
Tack för dina kommentarer!
single