Complete the code to create a lambda function that adds 5 to a number.
add_five = lambda x: x [1] 5 print(add_five(10))
The lambda function adds 5 to the input number using the + operator.
Complete the regular function to return the square of a number.
def square(num): return num [1] num print(square(4))
The function returns the number multiplied by itself to get the square.
Fix the error in the lambda function that should multiply two numbers.
multiply = lambda a, b: a [1] b print(multiply(3, 7))
The lambda function multiplies two numbers using the '*' operator.
Fill both blanks to create a dictionary comprehension that maps numbers to their squares using a lambda.
square_func = lambda x: x [1] x squares = {num: square_func(num) for num in range(1, 6) if num [2] 3} print(squares)
The lambda multiplies the number by itself to get the square. The comprehension includes numbers greater than 3.
Fill all three blanks to create a lambda that filters even numbers and returns their squares in a dictionary.
is_even = lambda n: n [1] 2 == 0 square = lambda x: x [2] x result = {num: square(num) for num in range(1, 11) if is_even(num) [3] True} print(result)
The lambda 'is_even' checks if a number divided by 2 has remainder 0 using '%'. The 'square' lambda multiplies the number by itself. The dictionary comprehension includes numbers where 'is_even(num) == True'.