Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Lab 6
- # Task 4
- with open("f1", "r") as file_f1:
- data = file_f1.read()
- with open("h", "w") as file_h:
- file_h.write(data)
- with open("f2", "r") as file_f2:
- data = file_f2.read()
- with open("f1", "w") as file_f1:
- file_f1.write(data)
- with open("h", "r") as file_h:
- data = file_h.read()
- with open("f2", "w") as file_f2:
- file_f2.write(data)
- # Lab 6
- # Task 13
- with open("h", "w") as file_h:
- with open("f", "r") as file_f:
- data = file_f.read()
- file_h.write(data)
- with open("g", "r") as file_g:
- data = file_g.read()
- file_h.write(data)
- # Lab 6
- # Task 17
- with open("f", "r") as file_f:
- data = map(int, f.read().split())
- with open("g", "w") as file_g:
- readed = 0
- while len(data) > readed
- data_max = data[readed]
- for i in range(100):
- data_max = max(data_max, data[i])
- readed += 100
- g.write(str(data_max))
- # Lab 5
- # Task 4
- text = input()
- i = 0
- last_plus = -1
- for sym in text:
- if sym == '+':
- last_plus = i
- i += 1
- if last_plus == -1:
- print(text)
- else:
- i = 0
- for sym in text:
- if i < last_plus and sym.islower():
- print('-', end='')
- else:
- print(sym, end='')
- i += 1
- # Lab 5
- # Task 9
- text = input()
- group_id = 0
- group_cnt = 0
- i = 0
- for sym in text:
- if sym.isalpha() and (i == 0 or not text[i - 1].isalpha()):
- j = i
- f_cnt = 0
- while j < len(text):
- if not text[j].isalpha():
- j -= 1
- break
- if text[j] == 'f':
- f_cnt += 1
- if j == (len(text) - 1):
- break
- j += 1
- if group_id < 3:
- print(f_cnt)
- group_id += 1
- if (not i == j) and text[i] == text[j]:
- group_cnt += 1c
- i += 1
- print(group_cnt)
- # Lab 5
- # Task 14
- n = int(input())
- data = input().split()
- print(data)
- need = '+-*'
- cnt1 = 0 # cnt of *
- cnt2 = 0 # cnt of +
- total_cnt = 0 # cnt of *,+,-
- for sym in data:
- if sym in need:
- total_cnt += 1
- if sym == '+':
- cnt1 += 1
- if sym == '*':
- cnt2 += 2
- print('Count of + is: ' + str(cnt1))
- print('Count of * is: ' + str(cnt2))
- print('Count of +,-,* is: ' + str(total_cnt))
Advertisement
Add Comment
Please, Sign In to add comment