Arithmetic operations
Class that performs basic arithmetic operations.
Source code in src/calculator.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
add(x, y)
A method for addition that takes two arguments and returns their sum.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
float
|
First summand. |
required |
y |
float
|
Second summand. |
required |
Returns:
Type | Description |
---|---|
float
|
Sum of the arguments. |
Source code in src/calculator.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
divide(x, y)
A method for division.
It takes two arguments and returns the result if the denominator is not zero, or raises an ValueError if the denominator is zero
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
float
|
Numerator. |
required |
y |
float
|
Denominator. |
required |
Returns:
Type | Description |
---|---|
float
|
Quotient. |
Source code in src/calculator.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
multiply(x, y)
A method for multiplication that takes two arguments and returns their product.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
float
|
Multiplicand. |
required |
y |
float
|
Multiplier. |
required |
Returns:
Type | Description |
---|---|
float
|
Product. |
Source code in src/calculator.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
subtract(x, y)
A method for subtraction that takes two arguments and returns their difference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
float
|
Minuend. |
required |
y |
float
|
Subtrahend. |
required |
Returns:
Type | Description |
---|---|
float
|
Difference between arguments. |
Source code in src/calculator.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|