<commit_before># Домашнее задание по уроку 1-5
# «Практика по использованию циклов, коллекций и функций»
# Выполнил <NAME> PY-3

students = [
    {'name': 'Василий', 'surname': 'Пупкин', 'sex': 'm',
     'experience': True, "evaluation": (9, 7, 4, 2, 7), 'exam': 9},
    {'name': 'Евгений', 'surname': 'Смернов', 'sex': 'm',
     'experience': True, 'evaluation': (10, 10, 9, 3, 7), 'exam': 10},
    {'name': 'Петр', 'surname': 'Смернов', 'sex': 'm',
     'experience': False, 'evaluation': (4, 2, 6, 1, 9), 'exam': 7},
    {'name': 'Дмитрий', 'surname': 'Давыдов', 'sex': 'm',
     'experience': False, 'evaluation': (4, 4, 4, 4, 4), 'exam': 2},
    {'name': 'Татьяна', 'surname': 'Брамс', 'sex': 'f',
     'experience': True, 'evaluation': (7, 9, 3, 10, 10), 'exam': 10},
    {'name': 'Мария', 'surname': 'Крынкина', 'sex': 'f',
     'experience': False, 'evaluation': (9, 8, 9, 5, 2), 'exam': 5}
]

students_count = len(students)
count_of_eval = len(students[0]['evaluation'])


def average_evals():
    count_all_evals = 0
    count_all_exam = 0

    for student in students:
        count_all_evals += sum(student['evaluation'])
        count_all_exam += student['exam']
        count_all_evals = round(count_all_evals / (students_count * count_of_eval), 1)
        count_all_exam = round(count_all_exam / students_count, 1)
    return count_all_evals, count_all_exam


def average_rate_count(what_count, value):
    count_evals = 0
    count_exams = 0
    count_filtered_students = 0

    for student in students:
        if what_count == 'sex':
            if student['sex'] == value == 'm':
                count_evals += sum(student['evaluation'])
                count_exams += student['exam']
                count_filtered_students += 1
            if student['sex'] == value == 'f':
                count_evals += sum(student['evaluation'])
                count_exams += student['exam']
                count_filtered_students += 1
        elif what_count == 'exp':
            if student['experience'] == value == True:
                count_evals += sum(student['evaluation'])
                count_exams += student['exam']
                count_filtered_students += 1
            if student['experience'] == value == False:
                count_evals += sum(student['evaluation'])
                count_exams += student['exam']
                count_filtered_students += 1

    count_evals = round(count_evals
                              / (count_filtered_students
                                 * count_of_eval), 1)
    count_exams = round(count_exams / count_filtered_students, 1)
    return count_evals, count_exams


def best_students():
    best_students_list = ''
    average_students_rating = []

    for student in students:
        best_counting_formula = (0.6 * (sum(student['evaluation'])
                                        / count_of_eval)) \
                                + (0.4 * student['exam'])
        average_students_rating.append(best_counting_formula)
    for index, bestStudent in enumerate(average_students_rating):
        if average_students_rating[index] == max(average_students_rating):
            best_students_list += '\n- ' + (students[index]['name'] + ' ' + students[index]['surname'])

    return best_students_list


print('\n' * 100)
print('Средние отценки:\n- Домашние задания: {}\n- Экзамен: {}'
      .format(average_evals()[0], average_evals()[1]))
print('\nСредняя отценка Мужчин\n- Домашние задания: {}\n- Экзамен: {}'
      .format(average_rate_count('sex', 'm')[0],
              average_rate_count('sex', 'm')[1]))
print('\nСредняя отценка Женщин\n- Домашние задания: {}\n- Экзамен: {}'
      .format(average_rate_count('sex', 'f')[0],
              average_rate_count('sex', 'f')[1]))
print('\nСредняя отценка студентов с Опытом\n- : Домашние задания: {}'
      '\n- Экзамен: {}'.format(average_rate_count('exp', True)[0],
                               average_rate_count('exp', True)[1]))
print('\nСредняя отценка студентов без Опыта\n- : Домашние задания: {}'
      '\n- Экзамен: {}'.format(average_rate_count('exp', False)[0],
                               average_rate_count('exp', False)[1]))
print('\nЛучший(е) студент(ы): {}'.format(best_students()))<commit_msg>Revert "Переименовал переменные"<commit_after># Домашнее задание по уроку 1-5
# «Практика по использованию циклов, коллекций и функций»
# <NAME> PY-3

students = [
    {'name': 'Василий', 'surname': 'Пупкин', 'sex': 'm',
     'experience': True, "evaluation": (9, 7, 4, 2, 7), 'exam': 9},
    {'name': 'Евгений', 'surname': 'Смернов', 'sex': 'm',
     'experience': True, 'evaluation': (10, 10, 9, 3, 7), 'exam': 10},
    {'name': 'Петр', 'surname': 'Смернов', 'sex': 'm',
     'experience': False, 'evaluation': (4, 2, 6, 1, 9), 'exam': 7},
    {'name': 'Дмитрий', 'surname': 'Давыдов', 'sex': 'm',
     'experience': False, 'evaluation': (4, 4, 4, 4, 4), 'exam': 2},
    {'name': 'Татьяна', 'surname': 'Брамс', 'sex': 'f',
     'experience': True, 'evaluation': (7, 9, 3, 10, 10), 'exam': 10},
    {'name': 'Мария', 'surname': 'Крынкина', 'sex': 'f',
     'experience': False, 'evaluation': (9, 8, 9, 5, 2), 'exam': 5}
]

count_of_students = len(students)
count_of_evaluations = len(students[0]['evaluation'])


def average_evaluations():
    count_of_all_evaluation = 0
    count_of_all_exam = 0

    for student in students:
        count_of_all_evaluation += sum(student['evaluation'])
        count_of_all_exam += student['exam']

        count_of_all_evaluation = round(count_of_all_evaluation / (count_of_students * count_of_evaluations), 1)
        count_of_all_exam = round(count_of_all_exam / count_of_students, 1)
    return count_of_all_evaluation, count_of_all_exam


def average_ratings_count(what_count, value):
    count_evaluations = 0
    count_exams = 0
    count_filtered_students = 0

    for student in students:
        if what_count == 'sex':
            if student['sex'] == value == 'm':
                count_evaluations += sum(student['evaluation'])
                count_exams += student['exam']
                count_filtered_students += 1
            if student['sex'] == value == 'f':
                count_evaluations += sum(student['evaluation'])
                count_exams += student['exam']
                count_filtered_students += 1
        elif what_count == 'exp':
            if student['experience'] == value == True:
                count_evaluations += sum(student['evaluation'])
                count_exams += student['exam']
                count_filtered_students += 1
            if student['experience'] == value == False:
                count_evaluations += sum(student['evaluation'])
                count_exams += student['exam']
                count_filtered_students += 1

    count_evaluations = round(count_evaluations
                              / (count_filtered_students
                                 * count_of_evaluations), 1)
    count_exams = round(count_exams / count_filtered_students, 1)
    return count_evaluations, count_exams


def best_students():
    best_students_list = ''
    average_students_rating = []

    for student in students:
        best_counting_formula = (0.6 * (sum(student['evaluation'])
                                        / count_of_evaluations)) \
                                + (0.4 * student['exam'])
        average_students_rating.append(best_counting_formula)
    for index, bestStudent in enumerate(average_students_rating):
        if average_students_rating[index] == max(average_students_rating):
            best_students_list += '\n- ' + (students[index]['name'] + ' ' + students[index]['surname'])
            # bestStudentsList сделал строкой, так как в дальнейшем использование этого списка не запланировано
            # и строка выводится красивее. Уверен есть другой способ, но не стал думать :)

    return best_students_list


print('\n' * 100)
print('Средние отценки:\n- Домашние задания: {}\n- Экзамен: {}'
      .format(average_evaluations()[0], average_evaluations()[1]))
print('\nСредняя отценка Мужчин\n- Домашние задания: {}\n- Экзамен: {}'
      .format(average_ratings_count('sex', 'm')[0],
              average_ratings_count('sex', 'm')[1]))
print('\nСредняя отценка Женщин\n- Домашние задания: {}\n- Экзамен: {}'
      .format(average_ratings_count('sex', 'f')[0],
              average_ratings_count('sex', 'f')[1]))
print('\nСредняя отценка студентов с Опытом\n- : Домашние задания: {}'
      '\n- Экзамен: {}'.format(average_ratings_count('exp', True)[0],
                               average_ratings_count('exp', True)[1]))
print('\nСредняя отценка студентов без Опыта\n- : Домашние задания: {}'
      '\n- Экзамен: {}'.format(average_ratings_count('exp', False)[0],
                               average_ratings_count('exp', False)[1]))
print('\nЛучший(е) студент(ы): {}'.format(best_students()))
{'fraction_non_alphanumeric': 0.15716053549330633, 'fraction_numerical': 0.01709978625267184, 'mean_word_length': 2.8335489435101335, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6681218', 'n_tokens_mistral': 3224, 'n_tokens_neox': 3142, 'n_words': 636}