top of page

Python Programming Help

Public·2 members

Write a program which can map() and filter() to make a list whose elements are square of even number in [1,2,3,4,5,6,7,8,9,10].

Here we use list of integer number from 1 to 10 -

 li = [1,2,3,4,5,6,7,8,9,10]

Now we find another using this list which is square of even numbers.


To do this here we use two function-


map() and filter()


Solution:


li = [1,2,3,4,5,6,7,8,9,10]
 
eve_num = map(lambda x: x**2, filter(lambda   x: x%2==0, li))
 
print(eve_num)
 

Output:

 [4, 16, 36, 64, 100]

Read more about python programming tutorial go the the codersarts programming tutorial link

7590 Views
bottom of page