“Built in Methods” In Python
Let’s start diving into Built in Methods , to make our lives easy 😃.
print("Hola! Built in Methods in Python 😄!)Built in Methods are methods or functions that comes with Python, they let’s us do several task much easier way then we can expect, by already writing the core logic behind those method, and as programmers we have to call those methods and pass the desired arguments.
Here’s the bonus tip!
This allows us to see the documentation for any method we like, giving us insight about
- Method’s Description
- Parameters
Don’t worry guys I got you!
Let’s get started, by learning some important Built in method, as follows:
- Map()
- Filter
- Zip
LET’S START LEARNING!
1. Map()
The map functions contains following parameters:
- function
- iterate able object
Here we defined a function, and then using map method we called the function, and also passing the iterate able object which is list “phone_brand”.
Get Mian’s stories in your inbox
Join Medium for free to get updates from this writer.
Wait wait wait…
Whats the list Constructor doing there?
As you know the output for map method here is a list of numbers that are the length for each phone brands length, but we need to store them as a list, that’s why we use list constructor.
The output if we print phone_brand_len 😃.
2. Filter ()
Filter methods contains two parameters,
- function
- iterate able object
Firstly we created a list of numbers, and the we defined a method which checks if a number is less then 20 or NOT.
Then we call filter method and pass the compare function along with the list of numbers. And the converted the output of filter method into a List.
Finally printed the result.
Wait Wait Wait…
What is difference between Map and Filter method then?
Basically Map Function returns all the values, however Filter Function return only those values that satisfies the condition according the function passed to Filter Function as an “argument”.
3. Zip()
Zip methods takes argument which is Iterate able Objects.
Here we created two arrays, one containing alphabets and other containing numbers.
We called Zip method, and passed both lists as an argument, and use list constructor to return a list.
Umm… Interesting 😄.
If you have noticed that both lists have different length size
- alphabets length was 4
- numbers length was 6
Point to note that Zip method will work using the length of iterate able object with minimum length.
So was it all?
No! still many Built in Methods left, but these were my favorite !
print("Don't Forget to explore at your Own 👌!")








