-
Notifications
You must be signed in to change notification settings - Fork 56
HW2_Grigoriants #3
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
…d_python into HW2_Grigoriants
…Git_and_python into HW2_Grigoriants
…d_python into HW2_Grigoriants
…hon into HW2_Grigoriants
Hw2 grigoriants
Hw2 grigoriants
Add division function
…hon into HW2_Grigoriants
Now it's great
Add function minus
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.
Хорошая работа!
Баллы:
- За каждую функцию: 1.6 * 5 = 8
- За README 1 + 1 доп. = 2
- За наличие всех форков и пулл-реквестов - 1 балл
Итого: 11 баллов
@@ -0,0 +1,13 @@ | |||
# HW2_Git_and_python by Git Dream Team | |||
Наша команда обеспечила Github комьюнити новейшим вычислительным механизмом. С её помощью школьная арифметика больше не создаст ни для кого проблем! Программа принимает на вход строку с некоторым математическим выражением и выводит число - результат вычисления этого выражения. | |||
|
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 на английском языке, чтобы в будущем ваш код могло использовать не только русско-говорящее сообщество. Лучше сразу привыкать;
- полезно приводить примеры кода, потому что по вашему описанию можно подать математическое выражение 1+2 и тогда ничего не сработает.
else: | ||
return num1 / num2 | ||
|
||
def plus(num1, num2): #sum of numbers |
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.
На будущее: # комментарий отделяют от кода двумя пробелами
num1 = float(my_string.split()[0]) | ||
num2 = float(my_string.split()[2]) | ||
sign = my_string.split()[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.
в целом рабочий вариант, но есть переиспользование кода, лучше было бы сделать так:
num1 = float(my_string.split()[0]) | |
num2 = float(my_string.split()[2]) | |
sign = my_string.split()[1] | |
num1, sign, num2 = my_string.split() | |
num1 = float(num1) | |
num2 = float(num2) |
ans = multiplication(num1, num2) | ||
elif sign == "/": | ||
ans = division(num1, num2) | ||
return ans |
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х строк.
ans = division(num1, num2) | ||
return ans | ||
answer = main() | ||
print(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.
Хороший нейминг. В целом код написан акуратно.
def multiplication(num1, num2): #multiplication of numbers | ||
return num1 * num2 | ||
|
||
def minus (num1, num2): |
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 minus (num1, num2): | |
def minus(num1, num2): |
### This will be our great calculator. Please contribute by writing one of the functions | ||
def division(num1, num2): #division of numbers | ||
if num2 == 0: | ||
return "Dude, for real?" |
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 "Dude, for real?" | |
print('Dude, for real?', file=sys.stderr) | |
os.exit(1) |
С модулями sys и os вы еще познакомитесь:)
def division(num1, num2): #division of numbers | ||
if num2 == 0: | ||
return "Dude, for real?" | ||
else: |
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.
else здесь не нужен
Homework done by Git Dream Team, teamlead - Grigoriants