Lambda functions!

In python3 we use the lambda operator, you can use it and is like declaring a function in only one line! But, here’s the question. Why we use the lambda operator? Is simple, there are many functions in python3 that we can use with this operator, to work with lists!

We declare the function like this:

lambda x,y:  x if x<y else y

this, will declare a function that takes those 2 parameters (x and y), and returns x if x is minor than y, and if it’s not, return y.

Soon, we are going to use this operator for more interesting programs. If it’s not clear yet, you can use this page where i learned it!

 

http://www.python-course.eu/python3_lambda.php

 

Or check this video:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s