Sitemap
Python in Plain English

New Python content every day. Follow to join our 3.5M+ monthly readers.

Follow publication

5 Useful Advanced Features of Python

4 min readMay 20, 2021

--

Press enter or click to view image in full size
Photo by Farzad Nazifi on Unsplash

Python is a popular and beautiful programming language used in data science, web development, maths, etc. It is simple to use and beginner-friendly to learn. But are you sure you know all the cool features it has to offer?

Today I’m going to show 5 common advanced topics/features in Python that you should learn.

1. Lambda Functions

In Python, a lambda function is an anonymous function (a nameless function) that can take any number of arguments. It can only contain a single expression.

For instance, here is a lambda that multiplies a number by four:

lambda x : x * 4

To use this lambda, you can assign it to a variable:

mult4 = lambda x : x * 4
mult4(15.0) # returns 60

Or you can call it right away:

(lambda x : x * 4)(15.0) # returns 60.0

Lambda functions are useful when the functionality is needed for a short while. In such a case, you don’t want to waste resources by creating a separate method.

Lambda Example

Let’s filter a list of numbers using the built-in filter() method. It takes two parameters:

  • A filtering function (a lambda function in this case)

--

--

No responses yet