Multiplication using Lambda Function

Tags: Lambda

Write a lambda function that takes two numbers and returns their product.

Example 1:

Input: 5, 3
Output: 15

Example 2:

Input: 7, 2
Output: 14

Lambda functions in python are a concise way to create functions. Use lambda to create a function that multiplies two numbers.

# Define the lambda function
multiply = lambda x, y: x * y

# Test the function
print(multiply(5, 3)) # Output: 15
print(multiply(7, 2)) # Output: 14

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!