Heaviside step function¶
The Heaviside step function can be defined as
\[\begin{split}H(x) = \begin{cases} 0, &x < 0, \\ 1, &x \ge 0. \end{cases}\end{split}\]
Write a function that implements the Heaviside step function following the given definition:
-
heaviside_step_function
(n)¶ Return the value of the Heaviside step function of n.
Parameters: n (float) – The number of which the Heaviside step function should be computed. Returns: The value of the Heaviside step function of n. Return type: int
Start by downloading the
exercise template
and editing
this file. You can run tests via
$ python heaviside_step_function.py test
to check whether you got a correct solution. You can also take a look at
one possible solution
.