Skip to content
CampusEduX

Problem 3: Matrix Multiplication Checker

Easypython
Learn the Concept: Linear Algebra Basics

Problem Description

Write a Python program that takes two matrices and first checks whether matrix multiplication between them is valid (based on shape compatibility). If valid, compute and print the result; if not, print a clear error message.

Input

Two matrices (as nested lists), representing matrix A and matrix B.

Output

Either the resulting matrix product, or a message stating the multiplication is not possible.

Constraints

  • Matrices can be of any reasonable size, but shapes must be checked before multiplying.

Example Input

text
matrix_a = [[1,2],[3,4]], matrix_b = [[5,6],[7,8]]

Example Output

text
Result: [[19 22] [43 50]]

Concepts Covered

Matrix shapes, np.matmul(), conditional shape checking.

Related Problems

  • Problem 1: Vector Addition and Scalar Multiplication
    Easy · python
    Solve Problem
  • Problem 2: Dot Product Calculator
    Easy · python
    Solve Problem
  • Problem 4: Transpose and Identity Verification
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...