Calculator Module Documentation

A module containing simple math operations.

python_demo_project_mjackdk.calculator.add_numbers(a: int, b: int)

Add two numbers together

Parameters:
  • a (int) – The base integer to use in the add operation

  • b (int) – The integer to add to the base integer

Returns:

The sum of both integers

Return type:

int

python_demo_project_mjackdk.calculator.average_numbers(numbers: list[int])

Average a list of numbers

Parameters:

numbers (list[int]) – The list of numbers to average

Returns:

The average of the numbers

Return type:

float

python_demo_project_mjackdk.calculator.divide_numbers(a: int, b: int)

Divide two numbers

Parameters:
  • a (int) – The base integer to use in the add operation

  • b (int) – The integer divide a by

Returns:

The quotient of the division operation

Return type:

float

python_demo_project_mjackdk.calculator.make_mathjs_request(a: int, b: int, operation: str)

Make a expression call against the MathJS API

Parameters:
  • a (int) – Base integer for the operation

  • b (int) – Integer to use with a in the operation

  • operation (str) – Operation to run against a and b

Raises:
  • ZeroDivisionError – Raised if division by 0

  • ValueError – Raised if not a supported operation

Returns:

  • int for non division operations

  • float for division operations

python_demo_project_mjackdk.calculator.multiply_numbers(a: int, b: int)

Multiple two numbers together

Parameters:
  • a (int) – The base integer to use in the multiply operation

  • b (int) – The integer to multiply against the base number

Returns:

The result of multiplying both numbers

Return type:

int

python_demo_project_mjackdk.calculator.subtract_numbers(a: int, b: int)

Subtract two numbers

Parameters:
  • a (int) – The base integer to use in the subtract operation

  • b (int) – The integer to subtract the base integer from

Returns:

The subtraction of both numbers

Return type:

int