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

See also

subtract

Subtraction

multiply

Multiplication

divide

Division

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.

See also

add

Addition

subtract

Subtraction

multiply

Multiplication

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

See also

add

Addition

subtract

Subtraction

divide

Division

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

See also

subtract

Subtraction

multiply

Multiplication

divide

Division

Examples

>>> subtract(1, 1)
0
>>> subtract(1, -1)
2
>>> subtract(0, 0)
0

Indices and tables