-
Notifications
You must be signed in to change notification settings - Fork 55
HW2_Stepanova #12
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_Stepanova #12
Changes from all commits
83fc175
7f8a92c
61c78b9
b2783ec
f741919
2da0f0e
5984690
fb22f15
351bf0f
776fc2f
5549922
144c985
55652f7
76c3603
f288ba9
982d79d
98b2856
c749b31
a3fbafd
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 @@ | ||
| .DS_Store/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # About calculator | ||
|
|
||
| A calculator is a program that performs basic arithmetic operations: addition, subtraction, multiplication and division. The calculator takes as input ( ) a string with some mathematical expression and prints a number - the result of calculating this expression. | ||
|
|
||
| # Requirements | ||
|
|
||
| Python 3.x (tested on Python 3.8 and above). | ||
|
|
||
| # Team | ||
|
|
||
| Shchekuteva Ekaterina, Revyakina Lilia, Loginova Olga, Stepanova Arina. | ||
|
|
||
| # Citation | ||
|
|
||
| ;) If you use calculator in your work, please cite [https://github.com/arrstepa/HW2_Stepanova]. | ||
|
|
||
| # Feedback and bug reports | ||
|
|
||
| If you have any troubles running calculator, please attach params.txt and calculator.log :) | ||
|
|
||
| # Screenshot of the team meeting | ||
|
|
||
|  |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| def multiple(a,b): | ||||||||||||||||||||||||||||||||||||||||||||||
| "Функция умножения двух чисел" | ||||||||||||||||||||||||||||||||||||||||||||||
| return a*b | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def substraction(a, b): | ||||||||||||||||||||||||||||||||||||||||||||||
|
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. Однобуквенные переменные стоит оставить только для счетчиков. Хорошо бы подошло |
||||||||||||||||||||||||||||||||||||||||||||||
| "Функция вычитания b из a" | ||||||||||||||||||||||||||||||||||||||||||||||
| return a - b | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def addition (a, b): | ||||||||||||||||||||||||||||||||||||||||||||||
| "Функция сложения двух чисел" | ||||||||||||||||||||||||||||||||||||||||||||||
| return a + b | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def division (a, b): | ||||||||||||||||||||||||||||||||||||||||||||||
| "Функция деления a на b" | ||||||||||||||||||||||||||||||||||||||||||||||
| if b!= 0: | ||||||||||||||||||||||||||||||||||||||||||||||
| return a/b | ||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||
| return "деление на 0!" | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+13
to
+18
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
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 main(): | ||||||||||||||||||||||||||||||||||||||||||||||
| exp=input("Введите выражение: ").split() | ||||||||||||||||||||||||||||||||||||||||||||||
| a,operation,b = float(exp[0]), exp[1], float(exp[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. Здорово, что сразу так сделано, в одну строку - в таких случаях это крайне уместно. |
||||||||||||||||||||||||||||||||||||||||||||||
| if operation == "+": | ||||||||||||||||||||||||||||||||||||||||||||||
| print(addition(a,b)) | ||||||||||||||||||||||||||||||||||||||||||||||
| elif operation == "-": | ||||||||||||||||||||||||||||||||||||||||||||||
| print(substraction(a,b)) | ||||||||||||||||||||||||||||||||||||||||||||||
| elif operation == "*": | ||||||||||||||||||||||||||||||||||||||||||||||
| print(multiple(a,b)) | ||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||
| print(division(a,b)) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+30
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
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| main() | ||||||||||||||||||||||||||||||||||||||||||||||
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.
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.
На будущее - все описания и комментарии стоит писать на английском.