-
Notifications
You must be signed in to change notification settings - Fork 56
HW2_Gorbarenko #5
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_Gorbarenko #5
Conversation
add delta function
add division function
Hw2 petrikov (add *)
Add sokol_sum function
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). Сейчас пока ладно, но дальше будет критично :)
Ну и нужно было сделать функцию main
))
a,b,c = input().split() | ||
if ("." in a) or ("." in c): | ||
a = float(a) | ||
c = float(c) | ||
elif ("," in a) or ("," in c): | ||
a = float(a.replace(',','.')) | ||
c = float(c.replace(',','.')) | ||
else: | ||
a = int(a) | ||
c = int(c) |
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.
Это и после функций нужно было завернуть в функцию main
. По заданию:
Функция main внутри себя должна принимать входное выражение, отдавать его на вычисление соответствующей функции, получать результат и печатать его на экран. Каждая из 4 функций лишь принимает определенное выражение от главной функции, вычисляет его и возвращает результат главной функции.
@@ -0,0 +1,39 @@ | |||
|
|||
a,b,c = input().split() |
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.
Здесь и везде ниже. Названия переменных a
, b
, c
абсолютно не информативны.
num1, operator, num2 = input().split()
@@ -0,0 +1,39 @@ | |||
|
|||
a,b,c = input().split() | |||
if ("." in a) or ("." in c): |
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 числа тут плохо. Попробуйте протестировать на вот таком инпуте:
1,2 + 1.2
if (b == "+"): #sokol_sum | ||
print(sokol_sum(a,c)) | ||
elif (b == "-"): #delta | ||
print(delta(a,c)) | ||
elif (b == "*"): #multi | ||
print(multi(a,c)) | ||
elif (b == "/") : #teilen | ||
print(teilen(a,c)) | ||
else: | ||
print("I dont know what it is") |
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.
И вот это должно было быть в main
.
Функция main внутри себя должна принимать входное выражение, отдавать его на вычисление соответствующей функции, получать результат и печатать его на экран. Каждая из 4 функций лишь принимает определенное выражение от главной функции, вычисляет его и возвращает результат главной функции.
Ну и плюс в ифах тут не нужны скобки. Вообще я бы сделал вот так:
# С учетом правок по названиям
result = "I dont know what it is"
if operator == "+":
result = addition(num1, num2)
elif operator == "-":
result = substraction(num1, num2)
elif operator == "*":
result = multiplication(num1, num2)
elif operator == "/":
result = division(num1, num2)
print(result)
def teilen(a,b): | ||
return(a / b) |
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.
teilen
? Почему неdivision
? ))- В return тут не нужны скобки.
def teilen(a,b): | ||
return(a / b) | ||
|
||
def delta(a, b): |
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.
delta
? Почему не substraction
? ))
def delta(a, b): | ||
return a - b | ||
|
||
def sokol_sum(a,b): |
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.
sokol
тут лишний )))
Можно назвать, например, addition
def sokol_sum(a,b): | ||
return a+b | ||
|
||
def multi(a, b): |
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.
В целом норм, но лучше тогда уж multiplication
))
@@ -0,0 +1,32 @@ | |||
# HW2_Git_and_python from Gorbarenko team | |||
*This is the repo for the second homework of the BI Python 2023 course* |
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.
Вроде эти строчки на английском, а дальше идет на русском ... как-то странно ))
No description provided.