Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to multiply two matrices A and B.
R Programming
result <- A [1] B Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using * which does element-wise multiplication instead of matrix multiplication.
Using + which adds matrices instead of multiplying.
✗ Incorrect
In R, the operator %*% is used for matrix multiplication.
2fill in blank
mediumComplete the code to multiply matrix M by vector v using matrix multiplication.
R Programming
result <- M [1] v Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using * which does element-wise multiplication and gives wrong results.
Using + which adds instead of multiplies.
✗ Incorrect
The %*% operator multiplies matrices and vectors properly in R.
3fill in blank
hardFix the error in the code to correctly multiply matrices X and Y.
R Programming
Z <- X [1] Y Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using * which multiplies elements individually, not matrices.
Using + which adds matrices instead of multiplying.
✗ Incorrect
Matrix multiplication in R requires the %*% operator, not the element-wise *.
4fill in blank
hardFill both blanks to create a matrix multiplication of A and B, then add matrix C.
R Programming
result <- (A [1] B) [2] C
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of %*% for matrix multiplication.
Using - instead of + for addition.
✗ Incorrect
First multiply A and B with %*%, then add C with +.
5fill in blank
hardFill all three blanks to multiply matrices X and Y, then subtract Z, and finally multiply by scalar s.
R Programming
final <- ((X [1] Y) [2] Z) [3] s
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of %*% for matrix multiplication.
Using + instead of - for subtraction.
Using %*% to multiply by scalar instead of *.
✗ Incorrect
Multiply X and Y with %*%, subtract Z with -, then multiply by scalar s with *.