Question:

Display powers of two using anonymous function

Program:

Explanation:

The lambda operator or lambda function is a way to create small anonymous functions, i.e. functions without a name. These functions are throw-away functions, i.e. they are just needed where they have been created.

The general syntax of a lambda function is quite simple:
lambda argument_list: expression

The argument list consists of a comma separated list of arguments and the expression is an arithmetic expression using these arguments. You can assign the function to a variable to give it a name.

Output:

Do share your feedback in comments to help us adding more programs like this.

Checkout more Python Programs

Click here

Leave a Reply