-
Notifications
You must be signed in to change notification settings - Fork 55
Hw2 zolotenkova #9
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?
Conversation
… into HW2_Zolotenkova
Hw2 zolotenkova
Add addition function
… into HW2_Zolotenkova
Add delenie func
Add differece
Edit file calculator.py
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 пробела, тогда блоки кода легко визуально определить.
- не используйте транслитерацию. Пишите названия переменных по-английски. В дальнейшем, ваш код могут захотеть использовать люди, которые не говорят-по русски, тогда названия переменных и функций им ни о чем не скажут.
Комментарии по README
- Молодцы, что написали про то, в каком виде нужно подавать данные.
- Здорово, что указали, кто из членов команды что делал.
- Лучше писать README на английском языке, чтобы вашим кодом могло пользоваться не только русско-говорящее сообщество.
Баллы:
- За каждую функцию: 1.6 * 5 = 8 баллов
- За README 1 + 1 - 2 балла
- За наличие всех форков и пулл-реквестов - 1 балл
Итого: 11 баллов
| @@ -0,0 +1,24 @@ | |||
| def summa(a, b): | |||
| answer = float(a) + float(b) | |||
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.
float'ы не нужны, потому что вы в функции main() уже сделали их float. Это не ошибка, но стилистически выглядит неудачно.
| @@ -0,0 +1,24 @@ | |||
| def summa(a, b): | |||
| answer = float(a) + float(b) | |||
| return (answer) | |||
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 не нужны
| return (answer) | |
| return answer | |
| answer = float(a) + float(b) | ||
| return (answer) | ||
| def raznost(a, b): | ||
| return(a - b) |
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(a - b) | |
| return a - b | |
| def delenie(a, b): | ||
| result = a / b | ||
| return result | ||
| def multiply(a,b): |
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 multiply(a,b): | |
| def multiply(a, b): | |
| return result | ||
| def multiply(a,b): | ||
| answer = a * b | ||
| return(answer) |
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(answer) | |
| return answer | |
| answer = a * b | ||
| return(answer) | ||
| def main(): | ||
| a, znak, b = input().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.
Лучше давать осознанные названия переменных. Не надо называть переменные и функции транслитерацией.
| a, znak, b = input().split() | |
| num1, sign, num2 = input().split() | |
| if znak == "+": | ||
| print(summa(a, b)) | ||
| elif znak == "-": | ||
| print(raznost(a, b)) | ||
| elif znak == "*": | ||
| print(multiply(a, b)) | ||
| elif znak == "/": | ||
| print(delenie(a, b)) |
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.
Такая реализация рабочая, но неоптимальная. Вы используете print() 4 раза. Лучше сделать запись результата в переменную, а потом 1 раз вызывать print.
| return(a - b) | ||
| def delenie(a, b): | ||
| result = a / b | ||
| return result |
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 после функции идет пропуск 2х строк
We`ve done it!