Skip to content

Hw2 voskoboinikov#13

Open
wwoskie wants to merge 17 commits intoPython-BI-2023:mainfrom
wwoskie:HW2_Voskoboinikov
Open

Hw2 voskoboinikov#13
wwoskie wants to merge 17 commits intoPython-BI-2023:mainfrom
wwoskie:HW2_Voskoboinikov

Conversation

@wwoskie
Copy link
Copy Markdown

@wwoskie wwoskie commented Sep 16, 2023

Team HW2 on python BI 2023/2024

Copy link
Copy Markdown

@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.

Отличная работа!

  • README понятный, приведены примеры. Только лучше писать README на английском языке.
  • Комментарии к коммитам отличные.
  • Хорошие, осознанные названия переменных и функций.
  • Здорово, что сделали реализацию с while.

Баллы:
За каждую функцию: 1.6 * 5 = 8 баллов
За README 1 + 1 доп. = 2 балла
За наличие всех форков и пулл-реквестов - 1 балл
Дополнительные баллы за pattern matching - 0.2 и 0.1 за while = 0.3 балла.

Итого: 11.3 балла

@@ -0,0 +1,35 @@
def addition(a, b):
return(a + b)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

скобки у return не нужны

Suggested change
return(a + b)
return a + b

@@ -0,0 +1,35 @@
def addition(a, b):
return(a + b)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

По PEP8 после функции делают 2 пропуска строки

return(a + b)

def subtraction(a, b):
return(a - b)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
return(a - b)
return a - b

return(a - b)

def multiplication(a, b):
return(a * b)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
return(a * b)
return a * b

return(a * b)

def division(a, b):
return(a / b)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
return(a / b)
return a / b

Comment on lines +19 to +22
calculator_func_dict = {'-': subtraction,
'*': multiplication,
'+': addition,
'/': division}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍


calc_string = input('Enter your expression: ')

while calc_string != 'exit':
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Здорово, что сделали возможность проводить столько вычислений, сколько нужно пользователю👍

calc_string = input('Enter your expression: ')

while calc_string != 'exit':
command = calc_parser(calc_string)[1]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно один раз вызвать функцию calc_parser() и потом разом записать в переменные элементы в список, а не трижды ее вызывать. Так работает, но выглядит неоптимально.
Например:

Suggested change
command = calc_parser(calc_string)[1]
numb1, command, numb2 = calc_parser(calc_string)

Comment on lines +24 to +35
calc_string = input('Enter your expression: ')

while calc_string != 'exit':
command = calc_parser(calc_string)[1]
if command in calculator_func_dict:
print(calculator_func_dict[command](calc_parser(calc_string)[0], calc_parser(calc_string)[2]))
else:
print('Seems like an invalid expression. Please, enter valid expression!')

calc_string = input('Enter your expression: ')

print('See you next time!')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Этот код тоже можно было обернуть в функцию

Suggested change
calc_string = input('Enter your expression: ')
while calc_string != 'exit':
command = calc_parser(calc_string)[1]
if command in calculator_func_dict:
print(calculator_func_dict[command](calc_parser(calc_string)[0], calc_parser(calc_string)[2]))
else:
print('Seems like an invalid expression. Please, enter valid expression!')
calc_string = input('Enter your expression: ')
print('See you next time!')
def main():
calc_string = input('Enter your expression: ')
while calc_string != 'exit':
command = calc_parser(calc_string)[1]
if command in calculator_func_dict:
print(calculator_func_dict[command](calc_parser(calc_string)[0], calc_parser(calc_string)[2]))
else:
print('Seems like an invalid expression. Please, enter valid expression!')
calc_string = input('Enter your expression: ')
print('See you next time!')
main()

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