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ösung
Danke für Ihr Feedback!
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Großartig!
Completion Rate verbessert auf 2.27
Challenge: Sales and Revenue
Swipe um das Menü anzuzeigen
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ösung
Danke für Ihr Feedback!
single