MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __str__

Method __str__

linear_algebra/src/lib.py:273–285  ·  view source on GitHub ↗

returns a string representation of this matrix.

(self)

Source from the content-addressed store, hash-verified

271 self.__height = h
272
273 def __str__(self) -> str:
274 """
275 returns a string representation of this matrix.
276 """
277 ans = ""
278 for i in range(self.__height):
279 ans += "|"
280 for j in range(self.__width):
281 if j < self.__width - 1:
282 ans += str(self.__matrix[i][j]) + ","
283 else:
284 ans += str(self.__matrix[i][j]) + "|\n"
285 return ans
286
287 def __add__(self, other: Matrix) -> Matrix:
288 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected