0% found this document useful (0 votes)
3 views1 page

Simple Python Lambda Function Questions

The document provides examples of simple Python lambda functions for various arithmetic operations, including addition, subtraction, multiplication, division, squaring, and cubing numbers. It also includes a lambda function to check if a number is greater than 10. Each example is accompanied by a print statement demonstrating the output.

Uploaded by

hihihih
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Simple Python Lambda Function Questions

The document provides examples of simple Python lambda functions for various arithmetic operations, including addition, subtraction, multiplication, division, squaring, and cubing numbers. It also includes a lambda function to check if a number is greater than 10. Each example is accompanied by a print statement demonstrating the output.

Uploaded by

hihihih
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Simple Python Lambda Function - Questions and Answers

Q1: Write a lambda function to add 5 to a number.


add_5 = lambda x: x + 5
print(add_5(10)) # Output: 15

Q2: Write a lambda function to subtract 3 from a number.


subtract_3 = lambda x: x - 3
print(subtract_3(8)) # Output: 5

Q3: Write a lambda function to multiply a number by 2.


multiply_2 = lambda x: x * 2
print(multiply_2(6)) # Output: 12

Q4: Write a lambda function to divide a number by 2.


divide_2 = lambda x: x / 2
print(divide_2(10)) # Output: 5.0

Q5: Write a lambda function to find the square of a number.


square = lambda x: x * x
print(square(4)) # Output: 16

Q6: Write a lambda function to find the cube of a number.


cube = lambda x: x * x * x
print(cube(3)) # Output: 27

Q7: Write a lambda function that returns True if a number is greater than 10.
greater_than_10 = lambda x: x > 10
print(greater_than_10(15)) # Output: True
print(greater_than_10(5)) # Output: False

You might also like