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

Method __init__

matrix/sherman_morrison.py:12–25  ·  view source on GitHub ↗

Initialize matrix with given size and default value. Example: >>> a = Matrix(2, 3, 1) >>> a Matrix consist of 2 rows and 3 columns [1, 1, 1] [1, 1, 1]

(self, row: int, column: int, default_value: float = 0)

Source from the content-addressed store, hash-verified

10 """
11
12 def __init__(self, row: int, column: int, default_value: float = 0) -> None:
13 """
14 <method Matrix.__init__>
15 Initialize matrix with given size and default value.
16 Example:
17 >>> a = Matrix(2, 3, 1)
18 >>> a
19 Matrix consist of 2 rows and 3 columns
20 [1, 1, 1]
21 [1, 1, 1]
22 """
23
24 self.row, self.column = row, column
25 self.array = [[default_value for _ in range(column)] for _ in range(row)]
26
27 def __str__(self) -> str:
28 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected