Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
277be23
Add subtract function
rentagr Sep 15, 2025
79c2569
Add management functions (main)
rentagr Sep 15, 2025
a9edfd1
insert add func, refactor main logic
Phuntik1980 Sep 17, 2025
4fab598
Merge pull request #1 from Phuntik1980/HW2_Islamova
rentagr Sep 17, 2025
728fa58
Implement multiply function
berdniklena Sep 17, 2025
2c1c9ed
Merge pull request #2 from berdniklena/HW2_Islamova
rentagr Sep 17, 2025
2a7632c
add substraction function
pannakontta Sep 17, 2025
e1649e9
Merge pull request #3 from pannakontta/HW2_Islamova
rentagr Sep 17, 2025
194c738
add calculator_devide.py with divide function
Mikhail-Dobryakov Sep 18, 2025
9a557fe
remove calculator_devide.py (incorrect filename)
Mikhail-Dobryakov Sep 18, 2025
c2f3318
add divide function with zero division
Mikhail-Dobryakov Sep 18, 2025
198aa93
Merge pull request #6 from Mikhail-Dobryakov/main
rentagr Sep 18, 2025
35b870e
Merged division function with main calculator.py
rentagr Sep 19, 2025
6827855
Fixed location of divide function
rentagr Sep 19, 2025
34cfb45
Fixed errors in the calculator: indentation, number check and divisio…
rentagr Sep 19, 2025
e174a8c
Added multiple images for README
rentagr Sep 19, 2025
f7302fa
Updated README with images
rentagr Sep 19, 2025
298933d
Updated README with images removed extra parts
rentagr Sep 19, 2025
41d6062
Updated README with images picture repair
rentagr Sep 19, 2025
0cc5f98
Updated README with images picture link repair
rentagr Sep 19, 2025
792617c
Updated README with images picture link repair_2
rentagr Sep 19, 2025
deeed66
Updated README with images picture link repair_3
rentagr Sep 19, 2025
1b79203
remowed TODOs
Phuntik1980 Sep 19, 2025
0491cdd
Merge pull request #9 from Phuntik1980/HW2_Islamova
rentagr Sep 19, 2025
96a7a9c
Update the main function, remove the cycle conflict
rentagr Sep 20, 2025
1416b43
Change the function description
rentagr Sep 20, 2025
59eb89e
Fix errors and change image path
Phuntik1980 Sep 21, 2025
61057d2
Merge pull request #10 from Phuntik1980/HW2_Islamova
rentagr Sep 21, 2025
e3d0d4d
Resolve conflict: accept existing Dev_team1.jpg
rentagr Sep 21, 2025
33f0100
Update README with images
rentagr Sep 21, 2025
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
66 changes: 66 additions & 0 deletions HW2_Islamova/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Python Calculator

A simple console-based calculator implementation in Python for basic mathematical operations.
## Features

- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Zero division error handling
- Support for negative numbers and floating-point values
- Input validation

## Installation

Clone the repository:


git clone https://github.com/rentagr/HW2_Git_and_python.git
cd HW2_Git_and_python

## Usage

Run the calculator:
python3 HW2_Islamova/calculator.py

Follow the prompts:

Enter a mathematical expression (example: 5 - 3):

The numbers and the operator must be separated by spaces.

Input first number: a;
Enter math operation: +, -, *, /;
Input second number: b;


## Example

Enter a mathematical expression (example: 5 - 3): 15.5 * 2
31

## Technologies Used

Python 3

Git version control

GitHub collaboration

## Development Team

Team Members:

Elena Ivankina - Add function, finding errors and inaccuracies, group communication organization
Anastasia Patrusheva - Sustract function, finding errors and inaccuracies, error correction
Elena Kalita - Multiply funcrion, finding errors and inaccuracies, error correction
Mikhail Dobryakov - Division function implementation with zero division handling, finding errors and inaccuracies
Renata I. Tagirovna - Project regulation, main calculator function, input validation

![Team](images/Dev_team1.jpg)

![Symbol](images/snake.jpg)


## This is an educational project developed for academic purposes
73 changes: 73 additions & 0 deletions HW2_Islamova/calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# calculator.py

AVAILABLE_OPERATORS = ['+', '-', '*', '/']

def add(a, b):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше, конечно, избегать названий в один символ, если это не счетчики.
num1, num2 оптимальнее.

result = a + b
return result

Comment on lines +6 to +8

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно было бы и

Suggested change
result = a + b
return result
return a + b

Не обязательно и не всегда нужно, особенно если вычисление длинное - но тут оно короткое и очевидное. Помогает читаемости кода.

def subtract(a, b):
result = a - b
return result

def multiply(a, b):
result = a * b
return result

def divide(a, b):
if b == 0:
print("Error: Division by zero is not possible")
return None
Comment on lines +18 to +20

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Классно, что об этом подумали, и еще более здорово, какую выбрали реализацию. Но вообще говоря, тут будет ошибка деления на ноль - и ладно. Но об ошибках и работе с ними еще будет. Клево, что возвращаете именно None, очень правильное направление мысли.

result = a / b
return result

def main ():
while True:
# Getting the input expression from the user
expression = input("Enter a mathematical expression (example: 5 - 3): ")
if not expression:
print("Error: empty input")
continue
# Split the string into parts by spaces
parts = expression.split()

# Checking the input format
if len(parts) != 3:
print("Error: Incorrect input format")
continue

# Checking whether the operands are numbers
try:
a = float(parts[0])
b = float(parts[2])
except ValueError:
print("Error: the numbers must be numeric or float types")
continue

# Checking the operand
operator = parts[1]
if operator not in AVAILABLE_OPERATORS:
print(f"Error: unsupported operator '{operator}'. Available operators: {AVAILABLE_OPERATORS}")
continue

# Select the appropriate function to calculate
if operator == '+':
result = add(a, b)
elif operator == '-':
result = subtract(a, b)
elif operator == '*':
result = multiply(a, b)
elif operator == '/':
result = divide(a, b)

# Output of the result if it is not None
if result is not None:
print(result)
return
else:
continue


# Start the program
if __name__ == "__main__":
main()
Binary file added HW2_Islamova/images/Dev_team.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added HW2_Islamova/images/Dev_team1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added HW2_Islamova/images/snake.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.