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
14251fd
add main section with error handling for input
PenguinNell Sep 15, 2025
2c44af0
Merge pull request #1 from PenguinNell/main
denspiry Sep 15, 2025
a63efb7
add the subtraction function
MargaritaLantsova Sep 15, 2025
e240514
add main_fun
PenguinNell Sep 15, 2025
1c3807d
Merge pull request #2 from PenguinNell/main
denspiry Sep 15, 2025
6d2c9bb
Merge branch 'main' of https://github.com/MargaritaLantsova/HW2_Spirin
MargaritaLantsova Sep 15, 2025
b66dab2
Add add_fun
CaptainLabMan Sep 15, 2025
a5ff463
add the subtract function
MargaritaLantsova Sep 15, 2025
880747d
Merge pull request #3 from CaptainLabMan/main
denspiry Sep 15, 2025
f637361
Merge branch 'main' into main
denspiry Sep 15, 2025
6cd0857
Merge pull request #4 from MargaritaLantsova/main
denspiry Sep 15, 2025
6ec8443
Add mult function
Sep 15, 2025
6e3a71a
add the call photo
MargaritaLantsova Sep 15, 2025
25f11ae
Update README.md
MargaritaLantsova Sep 15, 2025
b72b836
edit README.md
MargaritaLantsova Sep 15, 2025
a4cbc9d
2 update README.md
MargaritaLantsova Sep 15, 2025
66734b0
Merge branch 'main' into main
denspiry Sep 15, 2025
30dc2a1
Merge pull request #6 from dar1a-da/main
denspiry Sep 15, 2025
57829c3
Merge pull request #5 from MargaritaLantsova/main
denspiry Sep 15, 2025
9241232
fixed bug with mult fun
PenguinNell Sep 19, 2025
a44df1d
edit subtr fun
PenguinNell Sep 19, 2025
d279ebb
Merge pull request #7 from PenguinNell/main
denspiry Sep 20, 2025
89b9473
Add div_fun with zero-division condition
denspiry Sep 20, 2025
b0a7f4f
Fix bug in div_fun
denspiry Sep 20, 2025
e02db26
fix main and div funs
PenguinNell Sep 20, 2025
777d521
Merge pull request #8 from PenguinNell/main
denspiry Sep 20, 2025
2fb2e41
add work directory HW2_Spirin
denspiry Sep 21, 2025
0bd5455
remove old files
denspiry Sep 21, 2025
93dfca0
return original readme file
PenguinNell Sep 21, 2025
11a14dc
Merge pull request #9 from PenguinNell/main
denspiry 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
Binary file added HW2_Spirin/2025_09_15_20439.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions HW2_Spirin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# HW2_Git_and_python

We have written a mini-program `calculator.py `. The program accepts input (via `input()`) a string with some mathematical expression and prints a number - the result of calculating this expression.
The expression must consist of two numbers (`int` or `float`) and a mathematical operator between them (one of 4: `+ - * /`). All the specified elements are separated by spaces (example: `5 - 3`).

There are 5 functions implemented inside the script: `main' (which accepts the input expression) and 4 functions for each type of mathematical operations (addition, subtraction, multiplication and division).

✨✨✨✨✨
Our team:

Danil Spirin
Anastasiia Sycheva
Margarita Lantsova
Daria Chekanova
Andrey Nekrasov
✨✨✨✨✨

![Photo of a joint call](./2025_09_15_20439.png)
43 changes: 43 additions & 0 deletions HW2_Spirin/calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# def functions

def mult_fun(n1, n2):
res = n1 * n2
return res

def subtr_fun(n1, n2):
res = n1 - n2
return res

def add_fun(n1, n2):
return n1 + n2

def div_fun(n1, n2):
if n2 == 0:
res = 'You cannot divide by Zero'
else:
res = n1 / n2
return res


def main_fun(i):
n1, operator, n2 = i.split()

n1 = float(n1)
n2 = float(n2)

if operator == '+':
res = add_fun(n1, n2) # Addition

elif operator == '-':
res = subtr_fun(n1, n2) # Subtraction

elif operator == '*':
res = mult_fun(n1, n2) # Multiplication

elif operator == '/':
res = div_fun(n1, n2) # Division - add condition for "Division by zero!"

print(res)

input_ = input()
main_fun(input_)