-
Notifications
You must be signed in to change notification settings - Fork 56
Hw2 bredov #2
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?
Hw2 bredov #2
Changes from all commits
83e4006
d118b4f
9386ca6
df88a0b
1178ca3
914ab88
7ce7a2f
e3c3c01
1905db4
d28db21
acd6edc
4f429d7
00adcbe
a7abe5a
6e3117c
900f194
b2dd5d1
a31c891
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Script `calculator.py` performs all basic operations: addition, subtraction, multiplication and division. | ||
|
||
Credits: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Круто что вы перечислили обязанности каждого члена команды 👍 |
||
|
||
* Bobkov Gleb A. - implemented division; | ||
* Bagrova Olga E. - implemented addition; | ||
* Smertina Elena - implemented multiplication; | ||
* Matach Dmitri A. - implemented subtraction; | ||
* Bredov Denis V. - implemented `main()` function & team lead. | ||
|
||
 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Милота |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,25 @@ | ||||||||||
def divide(a, b): | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Здесь и далее лучше использовать более информативные названия переменных. Названия a и b не отражают содержимого. Лучше было бы, например, num1 и num2. Здесь за это баллы еще не снижаем, но с ДЗ 4 нейминг начнет влиять на оценку. |
||||||||||
return a/b | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Не хватает пробелов |
||||||||||
|
||||||||||
def add(a,b): | ||||||||||
return a+b | ||||||||||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Здесь и в других местах не хватает оформления пробелами. Всё правильно, но на будущее вот так будет выглядеть чуть лучше:
Suggested change
|
||||||||||
|
||||||||||
def multiply(x,y): | ||||||||||
return(x*y) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В таких случаях оформлять return скобками не принято. Так делают обычно если вы возвращаете несколько объектов |
||||||||||
|
||||||||||
def subtract(eq1,eq2): | ||||||||||
return(eq1-eq2) | ||||||||||
Comment on lines
+10
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Что значит eq? 😄 Мы же не уравнения вычитаем |
||||||||||
|
||||||||||
def main(): | ||||||||||
# eq = [int(i) if i.isdigit() else i for i in input().split()] | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Обычно закомменченный код не очень хорошо оставлять в репозитории. |
||||||||||
eq = input().split() | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Здесь было бы супер распаковать eq сразу в 3 элемента: |
||||||||||
match eq[1]: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Огонь что использовали pattern matching! |
||||||||||
case "+": | ||||||||||
return add(int(eq[0]), int(eq[2])) | ||||||||||
case "-": | ||||||||||
return subtract(int(eq[0]), int(eq[2])) | ||||||||||
case "*": | ||||||||||
return multiply(int(eq[0]), int(eq[2])) | ||||||||||
case "/": | ||||||||||
return divide(int(eq[0]), int(eq[2])) | ||||||||||
main() | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Такие вещи еще зачастую пишут через if __name__ == '__main__':
main() На следующей лекции как раз разберем зачем это нужно |
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.
Можно было бы сделать чуть более подробное описание вашего функционала. Пример использования какой-нибудь. Мало ли кто-то поставит ваш калькулятор себе но будет подавать выражение без пробелов ("2+2"). Но это уже совсем чтобы красоту навести.