#map_demo.py #filter too import math def area(r): return math.pi*r**2 radii = [1,2,3,4,5,6,10] areas = [area(r) for r in radii] print(areas) areas = list(map(area,radii)) print(areas) list1 = [("asdf",-12),("qwer",32),("fghj",13),("cvbn",34),("tyui",22)] def fahr(t): return t[0], 9/5*t[1] + 32 list2 = list(map(fahr,list1)) print(list2) list3 = list(map((lambda t: (t[0],9/5*t[1] + 32)), list1)) print(list3) radii_avg = sum(radii) / len(radii) radii_above_avg = list(filter(lambda r: r>radii_avg, radii)) print(radii_above_avg) list5 = ["asdf",0,"",234,"dghdfgh"] no_zeros_list = list(filter(None,list5)) #get rid of the 'zeroes' print(no_zeros_list) #multiple ints in one line of input my_ints_list = list(map(int,input("Enter ints on one line").split())) print(my_ints_list) x1, x2, x3 = map(eval,input("Enter the 3 scores: ").split()) #print(type(x3)) print(x1,x2,x3) # reduce import functools #Product of a list # reduce requires a function of two arguments print(functools.reduce(lambda x,y: x*y, my_ints_list))