-
Notifications
You must be signed in to change notification settings - Fork 56
Nekrasova's team pull-request #6
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
base: main
Are you sure you want to change the base?
Nekrasova's team pull-request #6
Conversation
This reverts commit 32381db.
Hw2 sapozhnikov pull request approved
Add substruct function pull request approved
Add def divide in calculator.py pull request approved
Adding addition function to calculator.py fixed merge conflict, pull request approved
Added team photo
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.
Не очень хорошо, что main() определяется до определения подфункций, вызываемых main(). Лучше соблюдать логику кода: сначала определение подфункций, а уже потом больших функций.
@@ -0,0 +1,62 @@ | |||
def main(expression: str): |
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.
Ого, аннотация типов!👍
@@ -0,0 +1,62 @@ | |||
def main(expression: str): | |||
expression_array = expression.split(' ') |
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.
expression_array = expression.split(' ') | |
expression_array = expression.split() |
Если хочется сделать сплит по пробельным символам, то советую такую конструкцию. В случае введения двойного пробела ваш вариант вставит " " в список, а предложенная - нет. 😌
expression_array = expression.split(' ') | ||
array_of_operands = [] | ||
|
||
try: |
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.
Очень уместное и лаконичное использование конструкции try-except для определения типов👍
|
||
try: | ||
left_int = int(expression_array[0]) | ||
array_of_operands.append(left_int) |
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.
array_of_operands.append(left_int) | |
nums.append(left_int) |
Логичнее было бы назвать переменную списком чисел, т.к. операнд - это +, -, /, *, и т.п.
left_float = float(expression_array[0]) | ||
array_of_operands.append(left_float) |
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.
left_float = float(expression_array[0]) | |
array_of_operands.append(left_float) | |
left_float = float(expression_array[0]) | |
array_of_operands.append(left_float) |
Куда потерялся пробел?😢
right_float = float(expression_array[2]) | ||
array_of_operands.append(right_float) |
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.
right_float = float(expression_array[2]) | |
array_of_operands.append(right_float) | |
right_float = float(expression_array[2]) | |
array_of_operands.append(right_float) |
Снова пробел...
|
||
answer = None | ||
|
||
if expression_array[1] == '+': |
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.
Уместнее было бы записать операнд в переменную и сравнивать её значение, но это так, перфекционизм
|
||
|
||
def add(arr_of_operands: list): | ||
return arr_of_operands[0]+arr_of_operands[1] |
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.
return arr_of_operands[0]+arr_of_operands[1] | |
return arr_of_operands[0] + arr_of_operands[1] |
По PEP8 тут нужны пробелы)) Сейчас на оценку не влияет, но в будущем обращайте внимание)
def add(arr_of_operands: list): | ||
return arr_of_operands[0]+arr_of_operands[1] | ||
|
||
def substruct(arr_of_operands: list): |
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.
def substruct(arr_of_operands: list): | |
def substract(arr_of_operands: list): |
Нейминг😌
return arr_of_operands[0]+arr_of_operands[1] | ||
|
||
def substruct(arr_of_operands: list): | ||
# substruct |
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.
Такие комментарии лучше удалять из кода, если они не несут дополнительной информации 😌
|
||
def substruct(arr_of_operands: list): | ||
# substruct | ||
return arr_of_operands[0]-arr_of_operands[1] |
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.
return arr_of_operands[0]-arr_of_operands[1] | |
return arr_of_operands[0] - arr_of_operands[1] |
|
||
def divide(arr_of_operands: list): | ||
if arr_of_operands[1] != 0: | ||
answer = arr_of_operands[0]/arr_of_operands[1] |
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.
answer = arr_of_operands[0]/arr_of_operands[1] | |
answer = arr_of_operands[0] / arr_of_operands[1] |
else: | ||
answer = 'Деление на 0!' |
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.
Хороший вариант сказать пользователю о делении на ноль!)
|
||
|
||
current_expression = input() | ||
main(current_expression) |
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.
main(current_expression) | |
if __name__ == "__main__": | |
current_expression = input() | |
main(current_expression) |
This project is leaded by nekrasovadasha22 with contributions from the following people: | ||
- grishchenkoira | ||
- anisssum | ||
- NSapozhnikov | ||
- Komarov I. |
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.
README малоинформативный. Не указан вклад каждого из членов команды, нет примеров использования программы: что она получает на вход и что выдает на выходе.
Здорово, что дана команда для вызова из терминала!
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.
Хорошая работа!
Основное задание - работа с гитом в команде - выполнено отлично; небольшие комментарии по стилю и логике кода, PEP8, отступам и неймингу переменных - это советы на будущее (в следующих дз на это будем обращать внимание).
Так что молодцы!
Итог:
Функции: 1.6 * 5 = 8
Ветки и пулл-реквесты: 1 балл
README: 0.5
Доп. балл за фото: 1
Итог: 10.5
Finished calculator.py project