my_package.calc

Module Contents

Functions

square(→ Union[int, float])

Returns the square of input x.

my_package.calc.square(x: Union[int, float]) Union[int, float]

Returns the square of input x.

Parameters

x (Union[int, float]) – An int or float, to be squared

Returns

The square of input x

Return type

Union[int, float]

Raises
  • TypeError – When input x is not an int or float

  • ValueError: – When input x is nan

Examples

>>> square(2)
4
>>> square(5)
25
>>> square('text')
TypeError: x should be of type int or float but is of: <class 'str'>
>>> square(float('NaN'))
ValueEror: x cannot be of type nan