Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions #1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
with open('text1.txt', mode='w') as write_dt:
data = input()
while data != '':
write_dt.write(f'{data}\n')
data = input()


5 changes: 5 additions & 0 deletions #2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
with open('text2.txt', 'r') as txt:
string = 1
for line in txt:
print(f'количество слов в строке {string} - {len(line.split())}')
string += 1
16 changes: 16 additions & 0 deletions #3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
with open('text3.txt', 'r', encoding='UTF-8') as txt:
average = 0
count = 0
for line in txt:
try:
salary = int(line.split(' - ')[1])
if salary < 20000:
print(line, end='')
average += salary
count += 1
except ValueError:
print('В файле обнаружена ошибка ввода заработной платы!')
except IndexError:
break
print(f'Средняя заработанная плата {average/count:.2f}')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хорошо


9 changes: 9 additions & 0 deletions #4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
numbers = {'One': 'один', 'Two': 'два', 'Three': 'три', 'Four': 'четыре'}
with open('text4.txt', 'r', encoding='UTF-8') as txt1:
with open('text4_1.txt', 'w', encoding='UTF-8') as txt2:
for line in txt1:
x = line.split(" — ")
try:
txt2.write(f'{numbers[x[0]]} — {x[1]}')
except KeyError:
print('В исходном файле обнаружена ошибка соответствия!')
8 changes: 8 additions & 0 deletions #5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from random import randint


with open('text5.txt', 'w', encoding='UTF-8') as txt:
for i in range(5):
txt.write(f'{str(randint(1, 100))} ')
with open('text5.txt', 'r', encoding='UTF-8') as txt:
print(sum(map(int, txt.readline().split())))
14 changes: 14 additions & 0 deletions #6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from itertools import cycle


dict = {}
with open('text6.txt', 'r', encoding='UTF-8') as txt:
for line in txt:
subject = ''.join(line.split()[:1])[:-1]
sum = 0
for a, n in zip(line.split()[1:], cycle([3, 4, 5])):
if a == '—':
continue
sum += int(a[:-n])
dict[subject] = sum
print(dict)
17 changes: 17 additions & 0 deletions #7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import json

dict_prof = {}
dict_aver = {}
with open('text7.txt', 'r', encoding='UTF-8') as txt:
count = 0
suma = 0
for line in txt:
name, ownership, income, costs = line.split()
profit = int(income) - int(costs)
dict_prof[name] = profit
suma += profit
count += 1
dict_aver['average_profit'] = suma/count
lists = [dict_prof, dict_aver]
with open("text7.json", "w") as txt:
json.dump(lists, txt)
4 changes: 4 additions & 0 deletions text1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sf
324
shrt
44444
3 changes: 3 additions & 0 deletions text2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fefef sfefsf
sdfsf jsdkfjsdf jsfkdf
sdfj
3 changes: 3 additions & 0 deletions text3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Иванов - 20000
Петров - 10000
Сидоров - 30000
4 changes: 4 additions & 0 deletions text4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
One — 1
Two — 2
Three — 3
Four — 4
4 changes: 4 additions & 0 deletions text4_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
один — 1
два — 2
три — 3
четыре — 4
1 change: 1 addition & 0 deletions text5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
58 64 37 84 66
3 changes: 3 additions & 0 deletions text6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Информатика: 100(л) 50(пр) 20(лаб)
Физика: 30(л) — 10(лаб)
Физкультура: — 30(пр) —
1 change: 1 addition & 0 deletions text7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"firm_1": 5500, "firm_2": 9400, "firm_3": -10000}, {"average_profit": 1633.3333333333333}]
3 changes: 3 additions & 0 deletions text7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
firm_1 ООО 10500 5000
firm_2 ОАО 10000 600
firm_3 ЗАО 20000 30000