重侧阶跃函数

这个 Heaviside step function 可以定义为

\[\begin{split}h(x)=\begin cases 0,&x<0,\\1,&x\ge 0.\结束案例\end{split}\]

按照给定的定义编写一个实现重侧步骤函数的函数:

heaviside_step_function(n)

返回的重侧阶跃函数的值 n .

参数

n (float) -- 应计算重侧阶跃函数的数目。

返回

重侧阶跃函数的值 n .

返回类型

int

首先下载 exercise template 编辑这个文件。您可以通过运行测试

$ python heaviside_step_function.py test

以检查您是否得到正确的解决方案。你也可以看看 one possible solution .