-
Notifications
You must be signed in to change notification settings - Fork 56
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
base: main
Are you sure you want to change the base?
HW2_Trofimov #10
Changes from all commits
0798400
fba1af8
7a204f7
4fea727
54afe03
f35e6ae
edd34be
1e81f26
ff921bb
a241e68
8b8e3a5
0cfc562
2cbb6ca
44f4b33
5058cda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Calculator | ||
Yep. Calculator. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep |
||
|
||
This magnificent piece of software engineering is done by these killas: | ||
|
||
 | ||
|
||
- 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Круто что вы перечислили обязанности каждого члена команды 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ды, оплошал, описание нашего инжира надо было доабвить |
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] | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В целом код рабочий, хоть и не очень питонячий. Особенно переменные типа calc_input и выглядят calc_input_lst громоздко (хотя нейминг по факту ок!). Это ничего страшного, мы с вами еще научимся опитонячивать наш код. Например, тут это можно было бы сделать так:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А вот это после лекции 3 мы знаем что вернет нам None. Потому что print выдает None и мы его перехватим в return. Это я кажется в ТЗ не очень хорошо прописал по поводу результата, но всё-таки либо There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. цэ убийственный кринж... каюсь.. |
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
def multiplication(number_1, number_2): | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Можно было бы это немного сократить:
Suggested change
Но это опять же про питонячесть, что понятие не шибко уловимое. |
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
def subtraction(number_1, number_2): | ||||||||||||||||||||||
res = number_1 - number_2 | ||||||||||||||||||||||
return res | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Такие вещи еще зачастую пишут через:
На следующей лекции как раз разберем зачем это нужно |
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.
А это тут что за зверь прокрался? 😁
Это какой то файл настроек папок ОС. Иногда встречаю его даже в тулах выложенных на GitHub. В общем следите за тем что добавляете в git, из-за таких как он поэтому и не стоит делать git add прям всей папки без разбора. Лучше поименно.
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.
Это про файл .DS_Store