Skip to content

Conversation

VovaGrig
Copy link

Homework done by Git Dream Team, teamlead - Grigoriants

VovaGrig and others added 30 commits September 11, 2023 18:20
Now it's great
Copy link

@albidgy albidgy left a 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 комьюнити новейшим вычислительным механизмом. С её помощью школьная арифметика больше не создаст ни для кого проблем! Программа принимает на вход строку с некоторым математическим выражением и выводит число - результат вычисления этого выражения.

Copy link

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
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 +19 to +21
num1 = float(my_string.split()[0])
num2 = float(my_string.split()[2])
sign = my_string.split()[1]
Copy link

Choose a reason for hiding this comment

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

в целом рабочий вариант, но есть переиспользование кода, лучше было бы сделать так:

Suggested change
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
Copy link

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)
Copy link

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):
Copy link

Choose a reason for hiding this comment

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

Suggested change
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?"
Copy link

Choose a reason for hiding this comment

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

Когда вы проводите операции над числами, вы ожидаете, что на выходе получите другое число. Здесь же вернется строка. В таких ситуациях лучше останавливать программу и выбрасывать ошибку. Например:

Suggested change
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:
Copy link

Choose a reason for hiding this comment

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

else здесь не нужен

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.

6 participants