szymcio10

Zadanie 2 - Python

May 4th, 2020
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. from operator import mul
  2. from functools import partial
  3. def fun1(lista):
  4.     return list(map(lambda x:x*len(lista),lista))
  5.  
  6. def fun2(lista):
  7.     return list(map(partial(mul,len(lista)),lista))
  8.  
  9. def mnozenie(czynnik1):
  10.     def mnozienie_1(czynnk2):
  11.         return czynnik1*czynnk2
  12.     return mnozienie_1
  13.  
  14. def fun3(lista):
  15.     return list(map(mnozenie(len(lista)),lista))
  16.  
  17. def main():
  18.     lst1=[1,3]
  19.     lst2=[1,3,5]
  20.  
  21.     print(fun1(lst1))
  22.     print(fun1(lst2))
  23.     print(fun2(lst1))
  24.     print(fun2(lst2))
  25.     print(fun3(lst1))
  26.     print(fun3(lst2))
  27.  
  28. if __name__ == '__main__':
  29.     main()
Advertisement
Add Comment
Please, Sign In to add comment