diff --git a/HW2_Tagirova/README.md b/HW2_Tagirova/README.md new file mode 100644 index 0000000..ec96db9 --- /dev/null +++ b/HW2_Tagirova/README.md @@ -0,0 +1,16 @@ +# Calculator project +This small project is a simple calculator of ours. The goal of this script is to upgrade our teamwork skills and get acquainted with git and Git Hub + +## How to use the software +1. Run the *calculator.py* script with `python3 calculator.py` from your Terminal. +2. The script will need you to enter a simple mathematical expression. Like "5 + 10" or "6 / 3". +3. Our project supports 4 basic operation: addition (+), substitution (-), multiplication (\*), division (/). Make sure your expression has only one those operators. +4. Enjoy your answer :) + +## List of developers +- Team Lead and main(): Alina Tagirova +- Addition: Maria Bicktasheva +- Substraction: Konstantin Yamschikov +- Multiplication: Arseniy Melnik +- Division: Sergey Losev +![](https://github.com/sergosev/HW2_Tagirova/blob/HW2_Tagirova/HW2_Tagirova/meet.jpg) diff --git a/HW2_Tagirova/calculator.py b/HW2_Tagirova/calculator.py new file mode 100644 index 0000000..44d8f61 --- /dev/null +++ b/HW2_Tagirova/calculator.py @@ -0,0 +1,37 @@ +# calculator.py + +def divide(x, y): + return x / y + +def multiply(x, y): + return x * y + +def subtract(x, y): + return x - y + +def add(x, y): + return x + y + +def main(): + num1, op, num2 = input().split() + a = float(num1) + b = float(num2) + + if op == '+': + res = add(a, b) + elif op == '-': + res = subtract(a, b) + elif op == '*': + res = multiply(a, b) + elif op == '/': + if b == 0: + print("Ошибка: деление на ноль") + return + res = divide(a, b) + else: + print(f"Ошибка: неизвестный оператор '{op}'") + return + print(int(res) if isinstance(res, float) and res.is_integer() else res) + +main() + diff --git a/HW2_Tagirova/meet.jpg b/HW2_Tagirova/meet.jpg new file mode 100644 index 0000000..1e59633 Binary files /dev/null and b/HW2_Tagirova/meet.jpg differ