HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Python Labs
  2. /Determinants by cofactors
MathematicsEasyHigh School (11–12)Algebra › Matrices and Determinants

Determinants by cofactors

You will write three functions: one that removes a row and a column, one that finds a determinant by expanding along the first row, and one that finds the cofactor of an entry. A matrix is a list of rows. The checker tests many matrices.

The idea. The minor of the entry in row iii and column jjj is the determinant that is left when row iii and column jjj are deleted. A determinant is the sum, along the first row, of (entry times cofactor), and the cofactor is the minor times (−1)i+j(-1)^{i+j}(−1)i+j. A 1×11 \times 11×1 determinant is its only entry.

Your tasks.

  1. Finish submatrix(M, i, j). Return M without row i and column j.
  2. Finish det(M). Expand along the first row, and call det again on the smaller matrices.
  3. Finish cofactor(M, i, j). Return the sign times the determinant of submatrix(M, i, j).

Run it first, just as it is. The checker at the end prints FAIL for each task. Then do the tasks one at a time, and run the program again after each one. A Hint appears under every check that still fails.

When every line says PASS, try det on a 4×44 \times 44×4 matrix of your own. Check it against the properties of the lesson.

StemPy LabContributed by StemPy Lab
python
Loading Python runtime…

A worked solution

Have you tried it?

Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.

Log in to save
← All Labs
← Transpose, symmetric and skew partsTriangles and straight lines →
More onAlgebra › Matrices and Determinants

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Evaluating a determinantDeterminants

More labs on this topic

  1. Inverse by row operationsHard
  2. Inverse by the adjointMedium
  3. Triangles and straight linesMedium
  4. Transpose, symmetric and skew partsMedium
  5. Matrix multiplication from scratch
Easy
All labs on this topic →