Kom igångKom igång gratis

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.

Den här övningen är en del av kursen

Practicing Coding Interview Questions in Python

Visa kurs

Interaktiv övning med praktiskt arbete

Testa den här övningen genom att slutföra den här exempelkoden.

# 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))
Redigera och kör kod