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.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Can you explain this in simpler terms?
What are some examples related to this topic?
Where can I learn more about this?
Awesome!
Completion rate improved to 2.27
Challenge: Sales and Revenue
Swipe to show menu
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.
Solution
Thanks for your feedback!
single