-
Notifications
You must be signed in to change notification settings - Fork 55
Hw2 tuliavko #11
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 tuliavko #11
Changes from all commits
8fdcb09
f750399
b32a5a2
9f5794e
100b3ad
f662f52
f23040d
844e658
3d6bd94
400a17b
8973d19
3ed78f9
be0a5df
9ce6f28
74b49fd
0974377
caab089
2686e28
7240f3f
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,34 @@ | ||
| # Calculator for basic arithmetic | ||
| This repository contains the script for calculating simple mathematical expressions. | ||
|
|
||
| ### System requirements: | ||
|
|
||
| Key packages and programs: | ||
| - [Python](https://www.python.org/downloads/) (version >= 3.9) | ||
|
|
||
| ### Run calculator: | ||
|
|
||
| Execute `extract_interface_residues.py` script provided here to start calculations. Then enter your expression in the line below in following format: the first number, the operation sign + for sum, - for subsctraction, / for division or \* for multiplication and the second number. Note that numbers must be separated by a space from the sign!! To run calculations press the `Enter` key. | ||
|
|
||
| For example: | ||
| ``` | ||
| # launch calculator | ||
| python extract_interface_residues.py | ||
| # input expressions | ||
| Enter your expression:1 + 2 | ||
| 3 | ||
|
Comment on lines
+17
to
+19
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. Вот это тут (в блоке с косыми кавычками) немного лишнее. Обычно в таком блоке пишется код/скрипты и прочее, что через интерфейс можно скопировать и вставить. |
||
| ``` | ||
|
|
||
| ### Authors: | ||
|
|
||
| *This is the repo for the second homework of the BI Python 2023 course* | ||
|
|
||
| - Badmadashiev Dorzhi | ||
| - Vedekhina Veronika | ||
| - Tulyavko Vlada | ||
| - Matveeva Ksenia | ||
| - Vaganova Polina | ||
|
|
||
|
|
||
|  | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # definitions of functions | ||
| def subtraction(num1, num2): | ||
| return num1 - num2 | ||
|
|
||
| def addition(num1, num2): | ||
| return num1 + num2 | ||
|
|
||
| def multiplication(num1, num2): | ||
| return num1 * num2 | ||
|
|
||
| def division(num1, num2): | ||
| if num2 == 0: | ||
| print('Error: division by zero! :(') | ||
| else: | ||
| return num1 / num2 | ||
|
Comment on lines
+12
to
+15
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. В целом идея неплохая, но 2 момента:
|
||
|
|
||
| def main(): | ||
| task = input('Enter your expression:') | ||
|
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.
|
||
| task = task.split(" ") | ||
|
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. В целом |
||
| num1, num2 = float(task[0]), float(task[2]) | ||
| mode = task[1] | ||
|
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. имхо, вместо |
||
| return operations[mode](num1, num2) | ||
|
|
||
|
|
||
| # dictionary with functions names | ||
| operations = {'/': division, | ||
| '-': subtraction, | ||
| '+': addition, | ||
| '*': multiplication | ||
| } | ||
|
Comment on lines
+25
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. Строго говоря, эта штука является константой, поэтому имеет смысл назвать её прописными буквами: |
||
| # start calculations | ||
| result = main() | ||
| print(result) | ||
|
Comment on lines
+32
to
+33
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 __name__ == '__main__':
result = main()
print(result) |
||
This file was deleted.
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.
Круто, вот только почему
extract_interface_residues.py? Файл же называетсяcalculator.py:)