map funtion:
instead of for loop we can use map function in a list....to calculate math mathical operations...
def func(x):
if x%2==0:
return x**x
else:
return x
where list is:
li=[3,3,4,4,4]
filter function:
we can filter the list using filter function like:
def func(x):
return x%2==0
where list is:
li=[3,3,4,4,4]
print(list(filter(func,li)
lambda:
func=lambda x: x+2
print(func(30))
optional parameters:
def func(x,y,z=4,p=9):
return x+y+z+p
func(1,2,4,5)
Counter Function:
counter function is used to count the number of items in the list, we can also subtract, add , update, clear, most_common, and, or
syntax:
from collections import Counter
c=Counter(list)
classmethod:
we do not require any objects to call classmethod
@classmethod
@staticmethod:we require some object to call staticmethod