Documentation for Toy_pkg¶
Toy_pkg Calculator¶
Calculator library containing basic math operations.
-
toy_pkg.calculator.
add
(first_term, second_term)¶ Add first and second term.
- Parameters
first_term (Number) – First term for the addition.
second_term (Number) – Second term for the addition.
- Returns
result – Result of the addition.
- Return type
Number
Examples
>>> add(1, 1) 2 >>> add(1, -1) 0 >>> add(0, 0) 0
-
toy_pkg.calculator.
divide
(first_term, second_term)¶ Divide first term by second term.
- Parameters
first_term (Number) – First term for the division.
second_term (Number) – Second term for the division.
- Returns
result – Result of the division.
- Return type
Number
- Raises
ZeroDivisionError – If second term is equal to zero.
Examples
>>> divide(1, 1) 1.0 >>> divide(1, -1) -1.0 >>> divide(4, 2) 2.0 >>> divide(1, 2) 0.5
-
toy_pkg.calculator.
multiply
(first_term, second_term)¶ Multiply first term by second term.
- Parameters
first_term (Number) – First term for the multiplication.
second_term (Number) – Second term for the multiplication.
- Returns
result – Result of the multiplication.
- Return type
Number
Examples
>>> multiply(1, 1) 1 >>> multiply(1, -1) -1 >>> multiply(0, 0) 0
-
toy_pkg.calculator.
subtract
(first_term, second_term)¶ Subtract second term from first term.
- Parameters
first_term (Number) – First term for the subtraction.
second_term (Number) – Second term for the subtraction.
- Returns
result – Result of the subtraction.
- Return type
Number
Examples
>>> subtract(1, 1) 0 >>> subtract(1, -1) 2 >>> subtract(0, 0) 0