开始使用免费开始使用

Define lambda expressions

Let's write some lambda expressions! You will be given three tasks: each will require you to define a lambda expression taking some values as arguments and using them to calculate a specific result.

本练习是课程的一部分

Practicing Coding Interview Questions in Python

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Take x and return x squared if x > 0 and 0, otherwise
squared_no_negatives = ____
print(squared_no_negatives(2.0))
print(squared_no_negatives(-1))
编辑并运行代码