Al3XS0n

Untitled

Mar 14th, 2022
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.38 KB | None | 0 0
  1. # Lab 6
  2. # Task 4
  3.  
  4. with open("f1", "r") as file_f1:
  5.     data = file_f1.read()
  6.     with open("h", "w") as file_h:
  7.         file_h.write(data)
  8.        
  9.  
  10. with open("f2", "r") as file_f2:
  11.     data = file_f2.read()
  12.     with open("f1", "w") as file_f1:
  13.         file_f1.write(data)
  14.  
  15. with open("h", "r") as file_h:
  16.     data = file_h.read()
  17.     with open("f2", "w") as file_f2:
  18.         file_f2.write(data)
  19.  
  20. # Lab 6
  21. # Task 13
  22. with open("h", "w") as file_h:
  23.     with open("f", "r") as file_f:
  24.         data = file_f.read()
  25.         file_h.write(data)
  26.     with open("g", "r") as file_g:
  27.         data = file_g.read()
  28.         file_h.write(data)
  29.        
  30. # Lab 6
  31. # Task 17
  32. with open("f", "r") as file_f:
  33.     data = map(int, f.read().split())
  34.     with open("g", "w") as file_g:
  35.         readed = 0
  36.         while len(data) > readed
  37.             data_max = data[readed]
  38.             for i in range(100):
  39.                 data_max = max(data_max, data[i])
  40.             readed += 100
  41.             g.write(str(data_max))
  42.  
  43. # Lab 5
  44. # Task 4
  45. text = input()
  46. i = 0
  47. last_plus = -1
  48. for sym in text:
  49.     if sym == '+':
  50.         last_plus = i
  51.     i += 1
  52. if last_plus == -1:
  53.     print(text)
  54. else:
  55.     i = 0
  56.     for sym in text:
  57.         if i < last_plus and sym.islower():
  58.             print('-', end='')
  59.         else:
  60.             print(sym, end='')
  61.         i += 1
  62.  
  63. # Lab 5
  64. # Task 9
  65. text = input()
  66. group_id = 0
  67. group_cnt = 0
  68. i = 0
  69. for sym in text:
  70.     if sym.isalpha() and (i == 0 or not text[i - 1].isalpha()):
  71.         j = i
  72.         f_cnt = 0
  73.         while j < len(text):
  74.             if not text[j].isalpha():
  75.                 j -= 1
  76.                 break
  77.             if text[j] == 'f':
  78.                 f_cnt += 1
  79.             if j == (len(text) - 1):
  80.                 break
  81.             j += 1
  82.         if group_id < 3:
  83.             print(f_cnt)
  84.             group_id += 1
  85.         if (not i == j) and text[i] == text[j]:
  86.             group_cnt += 1c
  87.     i += 1
  88. print(group_cnt)
  89.  
  90. # Lab 5
  91. # Task 14
  92. n = int(input())
  93. data = input().split()
  94. print(data)
  95. need = '+-*'
  96. cnt1 = 0 # cnt of *
  97. cnt2 = 0 # cnt of +
  98. total_cnt = 0 # cnt of *,+,-
  99. for sym in data:
  100.     if sym in need:
  101.         total_cnt += 1
  102.     if sym == '+':
  103.         cnt1 += 1
  104.     if sym == '*':
  105.         cnt2 += 2
  106. print('Count of + is: ' + str(cnt1))
  107. print('Count of * is: ' + str(cnt2))
  108. print('Count of +,-,* is: ' + str(total_cnt))
Advertisement
Add Comment
Please, Sign In to add comment