Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions HW2_Tagirova/README.md
Original file line number Diff line number Diff line change
@@ -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)
37 changes: 37 additions & 0 deletions HW2_Tagirova/calculator.py
Original file line number Diff line number Diff line change
@@ -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()

Binary file added HW2_Tagirova/meet.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.