You are on page 1of 1

list1 = [1,2,3,4,5]list2 = []for item in list1: list2.

append(item**2)#list
comrehension [item*item for item in list1]list1 = [1,2,3,4,5]list2 = [item+10 for
item in list1]print([item > 2 for item in list1])"""mapfilterreducelambda"""
map(function, list1)list1 = [1,2,3,4,5]def f1(x): return x*x*xf1(2)f1(10)
list(map(f1, list1))list1 = ['Amar','Akbar','Anthony']def f2(str1): return
len(str1)f2("Forsk")list3 = list(map(f2, list1))list1 = ['Jaipur','Kota','Udaipur']
def f3(str1): return 'pur' in str1list(map(f3, list1))list(map(lambda str1: 'pur'
in str1 , list1))list(filter(f3, list1))list(filter(lambda str1: 'pur' in str1 ,
list1))list1 = [1,2,3,4,5] def f4(x): return x > 2 list(filter(f4, list1))
list(filter(lambda x: x > 2, list1)) import functools list1 =
[1,2,3,4,5,6,7,8,9,10]def f5(x,y): return x+yfunctools.reduce(f5,
[1,2,3,4,5,6,7,8,9,10]) def f5(x,y): return x*yfunctools.reduce(f5,
[1,2,3,4,5,6,7,8,9,10]) functools.reduce(lambda x,y: x+y, [1,2,3,4,5,6,7,8,9,10])
map, reduce - big data handling hadoop - map, reducespark - map, reduce
Sanjay Ghemawatt1 = (1,2,3,4,5)#tuple are ready onlyprint (t1[0])print (t1[-1])
t1[0] = 10t2 = (2) #intt2 = (2,) #tupleorders = [ ["34587", "Learning Python, Mark
Lutz", 4, 40.95], ["98762", "Programming Python, Mark Lutz", 5, 56.80],
["77226", "Head First Python, Paul Barry", 3,32.95], ["88112",
"Einführung in Python3, Bernd Klein", 3, 24.99] ]for order in orders:
print(order[3]) t1=(1,2,3,4,5)print (t1[0])i = 90j = 80tup1 = (i,j)print(tup1)
def my_func (): return (1,2)tup1 = my_func()print(tup1)

You might also like