diff --git a/HW_Kokinos/README.md b/HW_Kokinos/README.md new file mode 100644 index 0000000..ae60fde --- /dev/null +++ b/HW_Kokinos/README.md @@ -0,0 +1,25 @@ +# Mathematical Expression Calculator + +This is a simple Python console program that calculates mathematical expressions with two operands. It accepts a string as input, which contains a mathematical expression with two numbers (integers or floats) and one of the four operators (+, -, \*, /). The program then calculates the result and displays it on the screen. + +### *Features* +___ +- Supports four basic arithmetic operations (+, -, \* , /) +- Handles both integers and floats +- Checks for division by zero errors +- Provides error handling for invalid input +### *Requirements* +___ +- Python 3.6 or later +### *To install* +___ +- Clone the repository or download the zip file +- Make sure Python 3 is installed on your machine +#### *Developed by* +___ +- Gorenkova Anastasiia (create main function) +- Kokinos Elena (create addition function) +- Parfenova Polina (create multiple function) +- Shchukina Elza (create difference function) +- Zhidkin Roman (create division function) +![team photo](imgs/team_photo.jpg) diff --git a/HW_Kokinos/calculator.py b/HW_Kokinos/calculator.py new file mode 100755 index 0000000..1ef96f9 --- /dev/null +++ b/HW_Kokinos/calculator.py @@ -0,0 +1,33 @@ +def main(expression): + parts = expression.split() + operator = parts[1] + num1, num2 = float(parts[0]), float(parts[2]) + result = 0 + if operator == '+': + result = addition(num1, num2) + elif operator == '-': + result = difference(num1, num2) + elif operator == '*': + result = multiple(num1, num2) + elif operator == '/': + if num2==0: + return 'На ноль делить нельзя!' + result = deviation(num1, num2) + return result + +def difference(a, b): + return (a - b) + +def multiple(a, b): + return (a * b) + +def deviation (x, y): + return (x/y) + +def addition(a, b): + return (a + b) + +print(main(input("Введите выражение: "))) + + + diff --git a/HW_Kokinos/imgs/team_photo.jpg b/HW_Kokinos/imgs/team_photo.jpg new file mode 100644 index 0000000..eab5a50 Binary files /dev/null and b/HW_Kokinos/imgs/team_photo.jpg differ