from randomimport randint
def func1(n):
return n %2
def func2(n):
return n *2 +3
if __name__ =='__main__':
nums = [randint(1,100)for iin range(10)]
print(nums)
b =list(filter(func1,nums))
print(b)
c =list(filter(lambda n : n %2, nums))
print(c)
print('#' *30)
d =list(map(func2,nums))
print(d)
e =list(map(lambda n : n *2 +3, nums))
print(e)
网友评论