A Pure-Python Matrix Class

medium
Checkpoint challenge
Solve this to show you know the material and jump straight to Unit 13. Everything before it counts as cleared.

Implement Matrix(rows) (a list of equal-length lists; raise ValueError otherwise) with:

  • shape property, T property (transpose), __eq__
  • + and - with another matrix of the same shape (else ValueError)
  • @ matrix multiplication (inner dimensions must match)
  • * by a number (both sides)
  • Matrix.identity(n) class method
  • __pow__(k) for a non-negative integer k on square matrices, using repeated squaring
#classes#linear-algebra2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
A Pure-Python Matrix Class · TechGradify