Skip to content

Comments

ДЗ к 7 уроку#5

Open
getblad wants to merge 1 commit intomasterfrom
lesson7
Open

ДЗ к 7 уроку#5
getblad wants to merge 1 commit intomasterfrom
lesson7

Conversation

@getblad
Copy link
Owner

@getblad getblad commented Sep 19, 2020

No description provided.

return ''

def __add__(self, other):
return Matrix([[i+n for i, n in zip(a, b)] for a, b in zip(self.matrix, other.matrix)])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это самое короткое и элегантное решение, что я видел)

matrix2 = [[1, 2, 3, 5], [1, 2, 3, 4], [1, 2, 2, 7]]
ma = Matrix(matrix)
ma2 = Matrix(matrix2)
c = ma + ma2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше обзывать переменные поинформативнее

if sub > 0:
return Cell(sub)
else:
print(f'Из клетки {self.get_name()} невозможно вычесть {other.get_name()}', end='')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да тут прямо можно влупить raise ValueError, чтобы неповадно было

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants