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
9 changes: 9 additions & 0 deletions task_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
file = open("task_1.txt", "w")

while True:
content = input("Введите текст: ")
if content == "":
break
else:
file.write(content + "\n")
file.close()
4 changes: 4 additions & 0 deletions task_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
qwe
sd
a

9 changes: 9 additions & 0 deletions task_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
count_str = 0
count_words = 0

with open("task_2.txt", "r") as file:
for line in file:
count_str += 1
count_words += len(line.split())

print(f"Колчиество строк {count_str}, количество слов {count_words}")
4 changes: 4 additions & 0 deletions task_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
firm_1 ��� 10000 5000
firm_2 ��� 50000 2000
firm_3 ��� 20000 29000
firm_4 �� 1000 200
15 changes: 15 additions & 0 deletions task_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
file = open("task_3.txt")
content = file.readlines()

sum_sal = 0
print("Зарплату меннее 20 000 имеют следующие сотрудники: ")

for el in content:
name, sal = el.split()
sum_sal += int(sal)
if int(sal) < 20000:
print(name)

print(f"Средняя заработная плата: {sum_sal / len(content)}")

file.close()
3 changes: 3 additions & 0 deletions task_3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
������ 20000
������ 10000
������� 30000
9 changes: 9 additions & 0 deletions task_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
my_dict = {"One": "Один", "Two": "Два", "Three": "Три", "Four": "Четыре"}

with open("task_4.txt", "r") as file:
content = file.readlines()

with open("task_4_new.txt", "w") as file:
for el in content:
a, b, c = el.split()
file.write(f"{my_dict.get(a)} {b} {c}\n")
4 changes: 4 additions & 0 deletions task_4.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 task_4_new.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
���� - 1
��� - 2
��� - 3
������ - 4
12 changes: 12 additions & 0 deletions task_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
content = input("Введите числа: ")
my_sum = 0

with open("task_5.txt", "w") as file:
file.writelines(content)

with open("task_5.txt", "r") as file:
new_content = file.read().split()
for el in new_content:
my_sum += int(el)

print(my_sum)
1 change: 1 addition & 0 deletions task_5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-5 5
23 changes: 23 additions & 0 deletions task_6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
file = open("task_6.txt")

content = file.readlines()
dic_content = {}
file.close()

for el in content:
sum_hour = 0
name = ""
el_sp = el.split()
for i in el_sp:
if i.endswith(":"):
name = i[:len(i) - 1]
if i.find("(л)") != -1 or i.find("(пр)") != -1 or i.find("(лаб)") != -1:
num = ""
for a in i:
if a.isdigit():
num += a
sum_hour += int(num)
dic_content.update({name: sum_hour})


print(dic_content)
3 changes: 3 additions & 0 deletions task_6.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 task_7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"firm_1": 5000, "firm_2": 48000, "firm_3": -9000, "firm_4": 800}, {"average_profit": 29266.666666666668}]
24 changes: 24 additions & 0 deletions task_7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import json

profit_middle = 0
count = 1
list_result = []
dic_result = {}

with open("task_7.txt") as file:
content = file.readlines()
for el in content:
list_content = el.split()
name = list_content[0]
profit = int(list_content[2]) - int(list_content[3])
if profit >= 0:
profit_middle += profit / count
count += 1
dic_result.update({name: profit})

list_result.append(dic_result)
list_result.append({"average_profit": profit_middle})

with open("task_7.json", "w") as file:
json.dump(list_result, file)

4 changes: 4 additions & 0 deletions task_7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
firm_1 ��� 10000 5000
firm_2 ��� 50000 2000
firm_3 ��� 20000 29000
firm_4 �� 1000 200