Wednesday, December 12, 2018

Python Ninja Bootcamp 34-filter function

Learn Python like a Professional! Take You from 0 to Hero






In this Python lecture, we will learn about the filter function.

"Filter is a function that takes a function and a sequence as a parameter. And returns the elements on which function is true".


Filter( ) in Python

Let's see the example filter function 


list(filter(lambda num:num>0,range(-5,5)))
>>[1,2,3,4]
In the above example, filter function is used to grab the elements, greater than zero. 




list(filter(lambda num:num%2==0,[0,1,2,3,4,5]))
>>[0,2,4]

In the above example, filter function is used to grab the elements, divisible by zero. 
 

EDITS ARE WELCOMED!!

In the next Blog, we will discuss zip( )
https://sngurukuls247.blogspot.com/2018/12/python-ninja-bootcamp-35-zip-function.html

......................................................................................................................................

Follow the link below to access Free Python Lectures-
https://www.youtube.com/channel/UCENc9qI7_r8KMf6-_1R1xnw

Instagram-
https://www.instagram.com/python.india/

View the Jupyter Notebook for this lecture

Download the Jupyter Notebook for this lecture 



Feel free contact me on-
Email - sn.gurukul24.7uk@gmail.com

No comments:

Post a Comment