INNER CODE UNIT · Python
n
webartifex/intro-to-python · 11_classes/sample_package/matrix.py:99
first, last, m, n = self[0], self[-1], self.n_rows, self.n_cols
return f"{name}(({first!r}, ...), ..., (..., {last!r}))[{m:d}x{n:d}]"
@property
def n_rows(self):
"""Number of rows in a Matrix."""
return len(self._entries)
@property
def n_cols(self):
"""Number of columns in a Matrix."""
return len(self._entries[0])
def __len__(self):
"""Number of entries in a Matrix."""
return self.n_rows * self.n_cols
def __getitem__(self, index):