-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlesson_last_p1.py
107 lines (82 loc) · 2.73 KB
/
lesson_last_p1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#-*- coding: utf-8 -*-
import string
import random
dict_name = {}
S = 0
def tsk_0 ():
with open ("input.txt", "r", encoding='utf-8') as f:
print("STEP 1: ")
for line in f:
line = line.strip()
line = line.split('.')
dict_name[line[0]] = int (line[1].strip())
print (line, end='\n')
print ()
print("STEP 2: SET LIST")
for second_name, value in dict_name.items():
print ("{:15} {}".format (second_name, value))
print()
print("STEP 2: Список студентов обучающиеся на оц. <= 3")
for second_name, value in dict_name.items():
S += value
if value <= 3:
print ("{:15} {}".format (second_name, value))
print()
print ("------")
mean = sum(dict_name.values()) / len(dict_name)
print ("Средний бал {:.2f}".format(mean))
print ("Средний бал {:.2%}".format(mean))
def tsk_1():
split_value = ['!', '?', '...', '.']
count_sentense = 0
with open ("input_two.txt", "r", encoding='utf-8') as f:
print("STEP 1: ")
text = f.read()
for char in split_value:
text = text.replace(char, ".")
sentense = text.split(".")
print('STEP 2', sentense)
print()
for i in sentense:
count_sentense += 1
print("STEP 2: КОЛ_ВО ПРЕДЛОЖЕНИЙ: ", count_sentense)
print()
count_word = 0
for s in sentense:
count_word += len(s.split(" "))
print("{:120} {}".format (s, count_word))
print("STEP 3: КОЛ_ВО СЛОВ: ", count_word)
print()
count_let = 0
no__ = text.replace('.', '')
no__ = no__.replace(' ', '')
no__ = no__.replace("’", '')
no__ = no__.replace(",", '')
print(no__)
print()
len_ = len(no__)
print("Всего букв в тексте: = ", len_)
print()
# for i in range(len_)
# print(string.punctuation)
# ll = len(string.punctuation)
# print(ll)
# for i in string.punctuation:
# print(i)
def tsk_w ():
row = 5
col = 5
table = []
with open("input_num.txt", "w", encoding='utf-8') as f:
for _ in range(row):
table.append([random.randint(-3, 3) for _ in range(col)])
print("step 1: ", table)
print()
print("step 2: вывод в виде таблицы")
for i in range(row):
print("<---------------------->")
for j in range(col):
f.write("{:{width}}".fotmat(i*j, width))
print(table[i][j], end=" ")
f.write ("\n")
print("<-ln.down->")