koulin

pps dz

Aug 19th, 2023
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1. # дз по итератору
  2. cards = []
  3. for i in ('Пики','Буби','Черви','Крести'):
  4.     for j in '6789jqka':
  5.         cards.append(i + ' ' + j)
  6. iterator = iter(cards)
  7. for i in range(36):
  8.     print(next(iterator))
  9.    
  10.    
  11.    
  12. # лямбда
  13. from functools import reduce
  14. lenarray = int(input())
  15. array = []
  16. for i in range(lenarray):
  17.     array += [int(input())]
  18. res = list(filter(lambda x: (x ** 2) % 9 == 0, array))
  19. ans = reduce(lambda x, y: x if x > y else y,res)
  20. print(ans)
  21.  
  22.  
  23.  
  24. # дз по f строкам
  25. ip = [int(input()) for i in range(4)]
  26. a, b, c, d = ip
  27. for temp in ["{:08b}.", "{:b}.", "{:o}.", "{}.", "{:x}."]:
  28.     print((temp * 4)[:-1].format(a, b, c, d))
  29.    
  30.    
  31. # дз по файлам
  32. #6
  33. def allstfile(namefile):
  34.     with open(namefile,'r') as f:
  35.         a = []
  36.         for line in f:
  37.             a += [line.rstrip("\n")]
  38.         endstring = " "
  39.         for i in range(len(a)):
  40.             endstring += a[i] + ' '
  41.         return endstring
  42. # 8
  43. def stringclean(string):
  44.     return string.strip("!?.")
  45.  
  46. #14
  47. def information(name):
  48.     dictionary = {}
  49.     with open(name,"r",encoding="utf-8") as f:
  50.         base = f.readlines()
  51.     for line in base:
  52.         L = line.split()
  53.         if L[2].isdigit():
  54.             dictionary[L[0]] = (L[1],L[2])
  55.     return dictionary
  56.  
  57.  
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment