-
Notifications
You must be signed in to change notification settings - Fork 55
HW_Kokinos #10
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?
HW_Kokinos #10
Changes from all commits
153a675
fffb030
23f8001
85c168b
cb13bc5
2571c6e
c1a6fc9
42d534c
370e871
7aace91
71ea5fe
3fe2475
f2d8390
46b8a83
337c9cb
58fa8aa
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,25 @@ | ||
| # Mathematical Expression Calculator | ||
|
|
||
| This is a simple Python console program that calculates mathematical expressions with two operands. It accepts a string as input, which contains a mathematical expression with two numbers (integers or floats) and one of the four operators (+, -, \*, /). The program then calculates the result and displays it on the screen. | ||
|
|
||
| ### *Features* | ||
| ___ | ||
| - Supports four basic arithmetic operations (+, -, \* , /) | ||
| - Handles both integers and floats | ||
| - Checks for division by zero errors | ||
| - Provides error handling for invalid input | ||
| ### *Requirements* | ||
| ___ | ||
| - Python 3.6 or later | ||
| ### *To install* | ||
| ___ | ||
| - Clone the repository or download the zip file | ||
| - Make sure Python 3 is installed on your machine | ||
| #### *Developed by* | ||
| ___ | ||
| - Gorenkova Anastasiia (create main function) | ||
| - Kokinos Elena (create addition function) | ||
| - Parfenova Polina (create multiple function) | ||
| - Shchukina Elza (create difference function) | ||
| - Zhidkin Roman (create division function) | ||
|  |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| def main(expression): | ||
| parts = expression.split() | ||
| operator = parts[1] | ||
| num1, num2 = float(parts[0]), float(parts[2]) | ||
| result = 0 | ||
|
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. Можно не задавать переменную result по дефолту 0. В любом случае вы её всегда создаете при вызове функций заново. Это опасно ещё и тем, что при введении такого выражения |
||
| if operator == '+': | ||
| result = addition(num1, num2) | ||
| elif operator == '-': | ||
| result = difference(num1, num2) | ||
| elif operator == '*': | ||
| result = multiple(num1, num2) | ||
| elif operator == '/': | ||
| if num2==0: | ||
| return 'На ноль делить нельзя!' | ||
|
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. Молодцы, что подумали о случае деления на ноль, но в питоне итак есть свой особый тип ошибок ZeroDivisionError, программа будет кидать её даже, если вы не поставите условие, поэтому можно не писать дополнительных проверок. Также в данном случае функция обычно возвращает числа, а здесь в качестве результата - строка. |
||
| result = deviation(num1, num2) | ||
| return result | ||
|
|
||
| def difference(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 и x/y. У вас отлично написано в главной функции num1 и num2. Стоит делать код с названиями переменных в одном стиле (-1 балл). |
||
| 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. Можно убрать скобки из всех return, они не повлияют на правильность исполнения кода. |
||
|
|
||
| def multiple(a, b): | ||
| return (a * b) | ||
|
|
||
| def deviation (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. По документации PEP8 тут не нужен пробел между названием функции и аргументами. Наверняка вы уже познакомились с классными ребятами black и flake8 (¬‿¬). |
||
| return (x/y) | ||
|
|
||
| def addition(a, b): | ||
| return (a + b) | ||
|
|
||
| print(main(input("Введите выражение: "))) | ||
|
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. Ридми написан на английском языке, поэтому лучше придерживаться английского языка при написании предупреждений и взаимодействии с пользователем. |
||
|
|
||
|
|
||
|
|
||
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.md: было бы здорово добавить в ридми примеры того, как использовать ваш тул (например, что нужно вводить 3 + 5 через пробел, так как без него падает ошибка) и написать конкретные команды по скачиванию. Это займет немного места, а человеку, который хочет использовать ваш тул, будет приятно)
О коммитах и структуре репозитория: Стоит похвалить команду за осмысленные названия коммитов! Так держать! Однако названия коммитов лучше писать с заглавной буквы + стоит избегать давать коммитам длинные названия как здесь 'create file calculator.py \n\n add additional function'
О коде будет комментарий чуть ниже в виде построчного ревью.
Баллы: 10/10 (README) + 10/10 (Forks) + 79/80 (код и коммиты) + 10 доп. =
= 99/100 + 10 доп. = 109 баллов
Будьте внимательнее, ветка, PR и папка должны называться HW2_Kokinos.
Вы проделали большую работу. Молодцы! (´。• ω •。`)
(тимлид, не забудь показать ревью всей команде)