Guest User

Untitled

a guest
Jul 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. origin_list = list(range(1, 10+1))
  2.  
  3. # [3,4,5,6,7,8,9,10,11,12]
  4. new_list = list(map(lambda x: x+2, origin_list))
  5. print(new_list)
  6.  
  7. # [1,4,9,16,25,36,49,64,81,100]
  8. new_list = list(map(lambda x: x**2, origin_list))
  9. print(new_list)
  10.  
  11. # [64,81,100]
  12. new_list = list(map(lambda x: x**2, origin_list))
  13. new_list = list(filter(lambda x : x>60, new_list))
  14. print(new_list)
  15.  
  16. # [55]
  17. new_list=[]
  18. from functools import reduce
  19. new_list.append(reduce(lambda x, y: x+y, origin_list))
  20. print(new_list)
  21.  
  22. # 55
  23. from functools import reduce
  24. result = reduce(lambda x, y : x+y, origin_list)
  25. print(result)
  26.  
  27.  
  28. # from functools import wraps
  29. # wraps(wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__'), updated=('__dict__',))
  30. # Decorator factory to apply update_wrapper() to a wrapper function
  31.  
  32. # Returns a decorator that invokes update_wrapper() with the decorated
  33. # function as the wrapper argument and the arguments to wraps() as the
  34. # remaining arguments. Default arguments are as for update_wrapper().
  35. # This is a convenience function to simplify applying partial() to
  36. # update_wrapper().
Add Comment
Please, Sign In to add comment