-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
H13: Shalaev Pavel #77
Open
uSeRNameeeeeeeeq
wants to merge
9
commits into
tamkovich:master
Choose a base branch
from
uSeRNameeeeeeeeq:h13
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
21b9dbb
home
uSeRNameeeeeeeeq b87c2e0
HW7: Shalaev Pavel
uSeRNameeeeeeeeq baa6809
hw11
uSeRNameeeeeeeeq 43bc74c
HW13: Shalaev Pavel
uSeRNameeeeeeeeq 2f139c0
fixed mistakes
uSeRNameeeeeeeeq 3a3e89a
fixed.2
uSeRNameeeeeeeeq da44a8b
fixed again
uSeRNameeeeeeeeq 26ac938
4
uSeRNameeeeeeeeq 3dc1db5
last commit
uSeRNameeeeeeeeq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
Создать класс Matrix. | ||
Атрибуты - data(содержит саму матрицу - список списков), n, m. | ||
Определить конструктор(с параметрами(передача размерности: n, m | ||
и диапазона случайных чисел: a, b), по-умолчанию | ||
(матрица 5 на 5 где все элементы равны нулю), копирования) , | ||
переопределить магический метод str для красивого вывода. | ||
Описать функции, которые принимают на вход объект класса Matrix. | ||
Функции позволяют искать максимальный элемент матрицы, минимальный, | ||
сумму всех элементов. | ||
Создать в файле main.py матрицу. | ||
Воспользоваться всеми описанными функциями и методам | ||
""" | ||
|
||
|
||
from matrix_utils.matrix_classes import Matrix | ||
from matrix_utils import matrix_funcs | ||
|
||
|
||
if __name__ == "__main__": | ||
matrix = Matrix(5, 5, 11, 33) | ||
matrix.gen_default_matrix() | ||
print(matrix) | ||
print(matrix_funcs.find_max_matrix_element(matrix)) | ||
print(matrix_funcs.find_min_matrix_element(matrix)) | ||
print(matrix_funcs.find_sum_matrix_elements(matrix)) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from random import randint | ||
|
||
|
||
class Matrix: | ||
def __init__(self, n: int, m: int, a: int, b: int) -> None: | ||
self.n = n | ||
self.m = m | ||
self.a = a | ||
self.b = b | ||
self._data: list[list] = None | ||
|
||
@property | ||
def data(self): | ||
pass | ||
|
||
@data.setter | ||
def data(self, data): | ||
self._data = data | ||
|
||
def gen_default_matrix(self) -> None: | ||
"""Сгенерировать матрицу по умолчанию (нулевую)""" | ||
self._data = [ | ||
[randint(self.a, self.b) for _ in range(self.n)] | ||
for _ in range(self.m)] | ||
return self._data | ||
|
||
def __str__(self) -> str: | ||
return f"your matrix is {self._data}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from matrix_utils.matrix_classes import Matrix | ||
|
||
|
||
def find_max_matrix_element(matrix: Matrix) -> int or float: | ||
return max(map(max, matrix._data)) | ||
|
||
|
||
def find_min_matrix_element(matrix: Matrix) -> int or float: | ||
return min(map(min, matrix._data)) | ||
|
||
|
||
def find_sum_matrix_elements(matrix: Matrix) -> int or float: | ||
result = 0 | ||
for elem in matrix._data: | ||
for number in elem: | ||
result += number | ||
return result |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В сигнатуре функции написано, что метод возвращает None, а тут ты возвращаешь целую матрицу