Skip to content

HW2_Trofimov #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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Copy link
Member

Choose a reason for hiding this comment

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

А это тут что за зверь прокрался? 😁
Это какой то файл настроек папок ОС. Иногда встречаю его даже в тулах выложенных на GitHub. В общем следите за тем что добавляете в git, из-за таких как он поэтому и не стоит делать git add прям всей папки без разбора. Лучше поименно.

Copy link
Member

Choose a reason for hiding this comment

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

Это про файл .DS_Store

Binary file not shown.
12 changes: 12 additions & 0 deletions HW2_Trofimov/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Calculator
Yep. Calculator.
Copy link
Member

Choose a reason for hiding this comment

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

Yep


This magnificent piece of software engineering is done by these killas:

![screenshot](https://github.com/michtrofimov/HW2_Git_and_python/assets/92677906/862d524c-c68b-4229-b67b-f92ea140af84)

- Ilia Popov ('multiplication' function)
- Julia Nechaeva ('addition' function)
- Ekaterina Shitik ('subtraction' function)
- Ricardo Milos / Pavel Grobushkin ('division' function)
- Michil Trofimov ('main' function)
Comment on lines +8 to +12
Copy link
Member

Choose a reason for hiding this comment

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

Круто что вы перечислили обязанности каждого члена команды 👍
Еще бы подписать тут кто тимлид.
И не хватает самого хотя бы небольшого описания вашей мини-программы magnificent piece of software engineering.

Copy link
Author

Choose a reason for hiding this comment

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

ды, оплошал, описание нашего инжира надо было доабвить

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions HW2_Trofimov/calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
def main():
calc_input = input()
calc_input_lst = calc_input.split()

operation = calc_input_lst[1]
number_1 = calc_input_lst[0]
Copy link
Member

Choose a reason for hiding this comment

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

number_1 и number_2 хорошие названия, молодцы! Главное что не a и b или не x и y. Я бы сократил, например, до num1 и num2. Но ваш вариант тоже ок.

number_1 = float(number_1)
number_2 = calc_input_lst[2]
number_2 = float(number_2)
Comment on lines +2 to +9
Copy link
Member

Choose a reason for hiding this comment

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

В целом код рабочий, хоть и не очень питонячий. Особенно переменные типа calc_input и выглядят calc_input_lst громоздко (хотя нейминг по факту ок!). Это ничего страшного, мы с вами еще научимся опитонячивать наш код. Например, тут это можно было бы сделать так:

Suggested change
calc_input = input()
calc_input_lst = calc_input.split()
operation = calc_input_lst[1]
number_1 = calc_input_lst[0]
number_1 = float(number_1)
number_2 = calc_input_lst[2]
number_2 = float(number_2)
num1, operator, num2 = input().split()
num1, num2 = float(num1), float(num2)

Copy link
Author

Choose a reason for hiding this comment

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

трюк со сплитом инпута в три переменные хорош...


if operation == "+":
res = addition(number_1, number_2)
elif operation == "-":
res = subtraction(number_1, number_2)
elif operation == "*":
res = multiplication(number_1, number_2)
elif operation == "/":
res = division(number_1, number_2)
return print(res)
Copy link
Member

Choose a reason for hiding this comment

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

А вот это после лекции 3 мы знаем что вернет нам None. Потому что print выдает None и мы его перехватим в return. Это я кажется в ТЗ не очень хорошо прописал по поводу результата, но всё-таки либо print(res), либо return res

Copy link
Author

Choose a reason for hiding this comment

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

цэ убийственный кринж... каюсь..



def multiplication(number_1, number_2):
Copy link
Member

Choose a reason for hiding this comment

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

Лучше было бы назвать функции глаголами: multuply, add, subtract, divide.

res = number_1 * number_2
return res
Comment on lines +23 to +24
Copy link
Member

Choose a reason for hiding this comment

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

Можно было бы это немного сократить:

Suggested change
res = number_1 * number_2
return res
return number_1 * number_2

Но это опять же про питонячесть, что понятие не шибко уловимое.



def subtraction(number_1, number_2):
res = number_1 - number_2
return res


Comment on lines +30 to +31
Copy link
Member

Choose a reason for hiding this comment

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

Не знаю автоформатировали ли вы код, но отдельное спасибо за все пробелы и пустые строки где это нужно!

def addition(number_1, number_2):
res = number_1 + number_2
return res


def division(n1, n2):
res = n1 / n2
return res


main()
Copy link
Member

Choose a reason for hiding this comment

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

Такие вещи еще зачастую пишут через:

if __name__ == '__main__':
    main()

На следующей лекции как раз разберем зачем это нужно

Binary file added HW2_Trofimov/screenshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.