# 5 Python lambda Function with Examples

Python lambda is a anonymous function. Its created with lambda keyword. We can assign many arguments with one expression.

### Syntax:

Lambda  Expression: arguments

### Use of Lambda function:

It is used to create a function within the function for short period of time.

In this tutorial, you will learn about Python lambda Function with Examples

### Example Program 1:  calculate power

` ` ``` power = lambda x: x ** 2 print(power(5)) ``` ` ` ` `

Output: 25

### Example Program 2: To print even numbers

` ` ``` my_list = [1,2,3,4,5,7,8,9,10] even = list(filter(lambda x: (x%2 == 0) , my_list)) odd = list(filter(lambda x: (x%2 != 0) , my_list)) print('Even Numbers',even) print('Odd Numbers',odd) ``` ` ` ` `

Output:

Even Numbers [2, 4, 8, 10]
Odd Numbers [1, 3, 5, 7, 9]

### Example Program 3 : lambda program with map function

` ` ``` my_list = [1,2,3,4,5,7,8,9,10] even = list(map(lambda x: (x%2 == 0) , my_list)) odd = list(map(lambda x: (x%2 != 0) , my_list)) # Output: [4, 6, 8, 12] print('Even Numbers',even) print('Odd Numbers',odd) ``` ` ` ` `

Output:

Even Numbers [False, True, False, True, False, False, True, False, True]
Odd Numbers [True, False, True, False, True, True, False, True, False]

### Example Program 4: Find biggest number

` ` ``` bigger_number = lambda x,y: x if (x>y) else y print(bigger_number(5,2)) ``` ` ` ` `

Output:

5

### Example Program 5: Find smallest number

` ` ``` small_number = lambda x,y: x if (x ```

`Output:`

``` 2 Related posts: No related posts. ```
``` ```
``` ```
``` admin Post navigation PrevNext Python 10 Best Public Speaking Courses , Tutorials with Certificates admin August 11, 2021 0 Python 10 Best PHP Courses Certification Courses 2019 admin February 15, 2020 0 Python Python enumerate() Function with examples admin May 20, 2019 0 Python Python Example Programs Python Program to Swap Two Variables admin May 20, 2019 0 Python Python Example Programs Python Program to Find Armstrong Number in an Interval admin May 20, 2019 0 Python Python Example Programs Python program to display calendar admin May 20, 2019 0 Leave a Reply Your email address will not be published. Required fields are marked *Comment * Name * Email * Website ```
``` ```
``` ```
``` ```
``` ```
``` ```
``` ```
``` ```
``` ```
``` Best CoursesBest Embedded Systems Courses Best Ruby On Rails Courses Best Autocad Courses Best IOS app development Courses Best MYSQL Courses Best Django Courses Best Node js Courses Udacity Computer Vision Nanodegree Review Udacity Natural Language Processing Nanodegree Review Udacity Deep Reinforcement Learning Nanodegree Review Udacity Data Engineer Nanodegree Review Udacity ai programming with python Nanodegree Review Udacity Blockchain Developer Nanodegree Review Udacity AI Product Manager Nanodegree Review Udacity Sensor Fusion Engineer Nanodegree Review Udacity Data visualization Nanodegree Review Udacity Cloud Developer Nanodegree Review Udacity Predictive Analytics for Business Nanodegree Review Udacity Marketing Analytics Nanodegree Review Udacity AI for Healthcare Nanodegree Review Udacity Data Engineer Nanodegree Review Udacity Intro to Machine Learning with PyTorch Nanodegree Review Udacity Intro to Machine Learning with TensorFlow Review Udacity DevOps Engineer for Microsoft Azure Nanodegree Review Udacity AWS Cloud Architect Nanodegree Review Udacity Flying Car Nanodegree Review Udacity Monetization Strategy Course Review Udacity Intro to Self-Driving Cars Nanodegree Review Udacity Data Science for Business Leaders Executive Program Review Best Nanodegree ReviewsUdacity School of Cloud Computing Review Udacity School of Data Science Review Udacity School of Cybersecurity Review Udacity School of Programming Review Udacity Cloud Native Application Architecture Nanodegree review Udacity Cloud Native Application Architecture Nanodegree review Udacity Cloud Computing for Business Leaders Nanodegree Review Udacity Cloud Native Application Architecture Nanodegree review Udacity Nanodegree Review Udacity Data Science Nanodegree Review Udacity Machine Learning Nanodegree Review Udacity Full Stack Web Developer Nanodegree Review Udacity Data analyst Nanodegree Review Udacity Deep Learning Nanodegree Review Udacity c++ nanodegree review Udacity react developer nanodegree review Udacity self driving car nanodegree review Udacity frontend developer nanodegree review Udacity dev ops nanodegree review Udacity Android Developer Nanodegree Review Udacity IOS Nanodegree Review Udacity Business Analyst Nanodegree Review Udacity Robotics Nanodegree Review Udacity UX Designer Nanodegree Review Udacity Java Developer Nanodegree Review Best Hadoop courses Latest CoursesBest Udacity Courses Best BlockChain Courses Best Python Courses Best Machine Learning Courses Best Deep Learning Courses Good Morning Images 2020 Inspirational quotes 2020 Udacity Deep Reinforcement Learning Nanodegree Review Udacity Data Engineer Nanodegree Review Udacity AI Programming with Python Nanodegree Review Udacity BlockChain Developer Nanodegree Review Udacity AI Product Manager Nanodegree Review Udacity Programming for Data Science Nanodegree with Python Review Udacity Ai for Trading Nanodegree Review Udacity Artificial Intelligence Nanodegree Review Udacity Data Structures and Algorithms Nanodegree Review Udacity Intel Edge AI for IoT Developers Nanodegree Review Udacity Digital Marketing Nanodegree Review Udacity Growth and Acquisition Strategy Nanodegree Review Udacity Product Manager Nanodegree Review Udacity Growth Product Manager Nanodegree Review Udacity AI for Business Leaders Nanodegree Review Udacity Data Streaming Nanodegree Review Udacity Programming for Data Science with R Nanodegree Review Udacity SQL Nanodegree Review Udacity data product manager Nanodegree Review Udacity Cybersecurity Nanodegree Review Udacity Javascipt Nanodegree Review Udacity Javascipt Nanodegree Review Udacity Cloud DevOps Engineer Nanodegree Review Udacity intro to Programming Nanodegree Review Udacity Android Basics Nanodegree Review Udacity Zero Trust Security Nanodegree Review Udacity Golang Nanodegree Review Udacity Cybersecurity for Business Leaders Nanodegree Review Udacity Digital Project Management Nanodegree Review Udacity Data Engineering with Microsoft Azure Nanodegree Review udacity ai enginner using microsoft azure nanodegree review udacity privacy engineer nanodegree review udacity site reliability engineer nanodegree review udacity sql for data analysisnanodegree reviewTrending CoursesCommission Hero Training Review Best Cat Prep Courses Best SAT Prep Courses Best TOEFL Prep Courses Best GRE Prep Courses Best GMAT Prep Courses Best TOEFL Prep Courses Best C Courses Best Golang Courses Best Docker Courses Best Big Data Courses Best Free Online Courses With Certificates Best Swift Courses Best Network Security Courses Best Cyber Security Courses Best DevOps Courses Best CCIE Certification Courses Best CCNA Certification Courses Udacity ethical hacker nanodegree review Udacity security analyst nanodegree review Udacity power BI nanodegree review Udacity Full Stack Javascript Developer nanodegree review Udacity cloud computing for business leaders nanodegree review Udacity cloud native application architecture nanodegree review Udacity digital freelancer nanodegree review Udacity security architect nanodegree review Udacity enterprise security nanodegree review Udacity machine learning devops engineer nanodegree review Best growth hacking courses Best hadoop coures Best Food Photography Courses Best Filmmaking Courses Best Filmmaking Courses Best Content Marketing Courses Best photography Courses Best Nutrition Courses Copyrigh @2020 for onlinecoursetutorials.com Reserved Cream Magazine by Themebeez ```
``` /* <![CDATA[ */ var wpcf7 = {"api":{"root":"https:\/\/onlinecoursetutorials.com\/wp-json\/","namespace":"contact-form-7\/v1"},"cached":"1"}; /* ]]> */ /* <![CDATA[ */ var cream_magazine_script_obj = {"show_search_icon":"1","show_news_ticker":"","show_banner_slider":"","show_to_top_btn":"1","enable_sticky_sidebar":"","enable_sticky_menu_section":"1"}; /* ]]> */ /* <![CDATA[ */ function heateorSssLoadEvent(e) {var t=window.onload;if (typeof window.onload!="function") {window.onload=e}else{window.onload=function() {t();e()}}}; var heateorSssSharingAjaxUrl = 'https://onlinecoursetutorials.com/wp-admin/admin-ajax.php', heateorSssCloseIconPath = 'https://onlinecoursetutorials.com/wp-content/plugins/sassy-social-share/public/../images/close.png', heateorSssPluginIconPath = 'https://onlinecoursetutorials.com/wp-content/plugins/sassy-social-share/public/../images/logo.png', heateorSssHorizontalSharingCountEnable = 0, heateorSssVerticalSharingCountEnable = 0, heateorSssSharingOffset = -10; var heateorSssMobileStickySharingEnabled = 0;var heateorSssCopyLinkMessage = "Link copied.";var heateorSssUrlCountFetched = [], heateorSssSharesText = 'Shares', heateorSssShareText = 'Share';function heateorSssPopup(e) {window.open(e,"popUpWindow","height=400,width=600,left=400,top=100,resizable,scrollbars,toolbar=0,personalbar=0,menubar=no,location=no,directories=no,status")} /* ]]> */ ```