To invert a 3x3 matrix in Python, we can use the numpy
library which provides a convenient function called inv()
. Here's the code:
main.py280 chars13 lines
Output:
main.py118 chars4 lines
Note that if your matrix is singular (i.e., has no inverse), the inv()
function will raise a LinAlgError
exception.
gistlibby LogSnag