coding utf-8 my_file open Men_2013 txt total_of_first_set_m ore total_

  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
103
104
105
106
107
108
109
110
# -*- coding: utf-8 -*-
my_file = open("Men_2013.txt", "r")
total_of_first_set_more = 0
total_of_second_set_more = 0
eq_totals = 0
count_of_games = 0
count_of_games_cat_1 = 0
count_of_games_cat_2 = 0
count_of_games_cat_3 = 0
count_of_games_cat_4 = 0
count_of_games_cat_5 = 0
qty_1 = 0 # количество матчей, в которых второй сет оказался ниже первого
qty_2 = 0
qty_3 = 0
qty_4 = 0
qty_5 = 0
total_const = 38.5
critical_common = 0
critical_1 = 0
critical_2 = 0
critical_3 = 0
critical_4 = 0
critical_5 = 0
for my_string in my_file:
try:
first_position = my_string.index('(')
second_position = my_string.index(')')
my_string = my_string[first_position+1:second_position]
totals = []
for current_set in my_string.split(','):
appending_total = 0
for current_set_of_one_player in current_set.split('-'):
current_set_of_one_player = int(current_set_of_one_player)
appending_total += current_set_of_one_player
totals.append(appending_total)
count_of_games += 1
if totals[1] < total_const:
critical_common += 1
if totals[0] > totals[1]:
total_of_first_set_more += 1
elif totals[0] < totals[1]:
total_of_second_set_more += 1
else:
eq_totals += 1
# раскладываю матчи по категориям:
# 1 категория - тотал первого сета от 0 до 33
# 2 34-35
# 3 36-37
# 4 38-39
# 5 40 и больше
if totals[0] <= 33:
count_of_games_cat_1 += 1
if totals[0] > totals[1]:
qty_1 += 1
if totals[1] < total_const:
critical_1 += 1
elif totals[0] == 34 or totals[0] == 35:
count_of_games_cat_2 += 1
if totals[0] > totals[1]:
qty_2 += 1
if totals[1] < total_const:
critical_2 += 1
elif totals[0] == 36 or totals[0] == 37:
count_of_games_cat_3 += 1
if totals[0] > totals[1]:
qty_3 += 1
if totals[1] < total_const:
critical_3 += 1
elif totals[0] == 38 or totals[0] == 39:
count_of_games_cat_4 += 1
if totals[0] > totals[1]:
qty_4 += 1
if totals[1] < total_const:
critical_4 += 1
elif totals[0] >= 40:
count_of_games_cat_5 += 1
if totals[0] > totals[1]:
qty_5 += 1
if totals[1] < total_const:
critical_5 += 1
except:
pass
print 'qty_of_games: ', count_of_games
print 'total_of_second_set_more: ', total_of_second_set_more
print 'percent of 2nd:', float(total_of_second_set_more)/float(count_of_games) * 100, '%'
print 'critical: ', critical_common, '(', float(critical_common)/float(count_of_games) * 100,'%)'
print '----------------------------'
print '1 cat: ', count_of_games_cat_1, \
'qty:', qty_1, '(', float(qty_1)/float(count_of_games_cat_1)*100, '%)',\
'critical: ', critical_1, '(', float(critical_1)/float(count_of_games_cat_1)*100, '%)'
print '2 cat: ', count_of_games_cat_2, \
'qty:', qty_2, '(', float(qty_2)/float(count_of_games_cat_2)*100, '%)',\
'critical: ', critical_2, '(', float(critical_2)/float(count_of_games_cat_2)*100, '%)'
print '3 cat: ', count_of_games_cat_3, \
'qty:', qty_3, '(', float(qty_3)/float(count_of_games_cat_3)*100, '%)', \
'critical: ', critical_3, '(', float(critical_3)/float(count_of_games_cat_3)*100, '%)'
print '4 cat: ', count_of_games_cat_4, \
'qty:', qty_4, '(', float(qty_4)/float(count_of_games_cat_4)*100, '%)', \
'critical: ', critical_4, '(', float(critical_4)/float(count_of_games_cat_4)*100, '%)'
print '5 cat: ', count_of_games_cat_5, \
'qty:', qty_5, '(', float(qty_5)/float(count_of_games_cat_5)*100, '%)', \
'critical: ', critical_5, '(', float(critical_5)/float(count_of_games_cat_5)*100, '%)'