Skip to content

HW2_Kalygina#17

Open
AnnaKalygina wants to merge 28 commits intoPython-BI-2024-25:mainfrom
AnnaKalygina:HW2_Kalygina
Open

HW2_Kalygina#17
AnnaKalygina wants to merge 28 commits intoPython-BI-2024-25:mainfrom
AnnaKalygina:HW2_Kalygina

Conversation

@AnnaKalygina
Copy link

No description provided.

AnnaKalygina and others added 28 commits September 19, 2024 20:07
Добавлена фукнция деление
Add subtraction by Kachanovskii
Replaced return with print() in main()
Copy link

@iam28th iam28th left a comment

Choose a reason for hiding this comment

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

приветствую!

в целом всё здорово.
из недочётов:

  • сообщения к коммитам должны быть на английском и начинаться с императива (Add multilply вместо Added multiply) -6б
  • по возможности старайтесь добавлять файлы в проект локально через git (а не через браузер);
  • вместо Substraction 2.0/3.0 лучше прямо писать, чем эти версии отличаются (например, add function arguments, correct return statement...); -1б
  • нет особого смысла писать в commit message, кто автор: места там немного, а авторство git и так отслеживает; -1б
  • есть небольшие минусы в коде (в частности, различные отступы); -5б

по баллам:
readme 10/10
форки 10/10
коммиты и код: 67/80
+10 доп.баллов

итого у вас 87 + 10/100 баллов за это дз.
хорошая работа!

Our code implements a simple calculator that performs four different mathematical operations: addition, subtraction, multiplication, and division.
The calculator accepts input in the form of a string `"int_1 operator int_2"`, where:

- int_1 and int_2 are numbers (either integers or floats).
Copy link

Choose a reason for hiding this comment

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

int_{1,2} - не самые удачные обозначения для чего-то, что может быть either int or float

def multiply(x, y):
return x * y

## divide()
Copy link

Choose a reason for hiding this comment

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

комментарии в данном случае скорее излишни

ещё у вас разные отступы - где-то 2 пробела, где-то 4

Comment on lines +39 to +41
if y == 0:
return "На ноль делить нельзя"
else: return(x / y)
Copy link

Choose a reason for hiding this comment

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

здесь пара моментов:

  1. после else: принятно переходить на новую строку с увеличенным уровнем индентации

  2. в случаях когда обе ветки в if/else блоке заканчиваются return-ом, обычно "экономят отступы", т.е. вместо

  if y == 0:
     return "На ноль делать нельзя"
  else:
     return x / y

скорее напишут

  if y == 0:
    return "На ноль делить нельзя"
  return x / y
  1. круто, что вспомнили про особый случай с делением!
    при этом сам питон об этом тоже помнит, и напечатает вам ZeroDivisionError с понятным сообщением и traceback-ом
    т.е. зачастую (обычно в достаточно тривиальных случаях) можно самим с ошибками не заморачиваться и делегировать всё это питону

else:
result = "Не то!"

print(result)
Copy link

Choose a reason for hiding this comment

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

огонь, сохранение в переменную здесь идеалогически верно

Comment on lines +5 to +6
expression = input()
expression = expression.split(" ")
Copy link

Choose a reason for hiding this comment

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

Suggested change
expression = input()
expression = expression.split(" ")
expression = input().split()

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.

5 participants