SHARE
TWEET

Untitled

a guest Jul 21st, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #-------------------------------MAP--------------------
  2. # num= ['6','5','33']
  3. #
  4. # num= list(map(int,num))
  5. # print(map(int,num))
  6. # # for i in range(len(num)):
  7. # #     num[i]=int(num[i])
  8. # num[2]=num[2]+1
  9. # #print( num[2])
  10. # # def sq(a):
  11. # #     return a*a
  12. #
  13. # print(square)
  14. # num1=[2,3,8,69,66,8]
  15. # square=list(map(lambda x:x*x,num1))
  16.  
  17. # def square(a):
  18. #     return a*a
  19. #
  20. # def cube(a):
  21. #     return a*a*a
  22. # func=[square,cube]
  23. # #list1=[7,8,56,3,44,88,5]
  24. # for i in range(5):
  25. #     val=list(map(lambda x:x(i),func))
  26. #     print(val)
  27. #--------------------------------------FILTER-------------------------------------------------
  28.  
  29. # list3=[2,7,6,5,4,6,5,2,1]
  30. # def is_greater_5(num):
  31. #     return num>5
  32. # gr_than_5=list(filter(is_greater_5,list3))
  33. # print(gr_than_5)
  34. "--------------------------------------REDUCE----------------------------------------------------"
  35.  
  36. from functools  import reduce
  37. list1=[1,6,4,8,9,3]
  38. num=reduce(lambda x,y:x+y,list1)
  39. # num=0
  40. # for i in list1:
  41. #     num=num +i
  42. # print(num)
  43. print(num)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top