Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
Write a lambda function that doubles a given number.
Think about how you would multiply a number by 2.
What does the following code return? list(map(lambda x: x + 1, [1, 2, 3]))?
Consider what happens when you add 1 to each element.
What is the primary purpose of a lambda function in Python?
Remember, they are called 'anonymous' for a reason!
True or False: Lambda functions can take multiple arguments.
Think about your previous examples with multiple inputs.
Create a lambda function that takes a list of strings and returns a list with only the strings that have more than 3 characters.
How do you measure the length of a string?
Write a function using lambda to sort a list of tuples based on the second element and demonstrate it with a list of tuples (number, name).
Remember how to access tuple elements.
4 more questions in this section. Enroll free to practise them all.
Enroll free