/
AZD
/
Virtualization_Exam
Обзор
Документация
Войти
/
AZD
/
Virtualization_Exam
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
src/exam.py
75 строк
2 KB
55AZD55
add correct pharts
11 июн 2026, 12:43
11 июн 2026, 12:43
14efff3
Код
Авторство
О чём код?
import random import math def golden_ratio(n: int): CONST_F = (1 + math.sqrt(5)) / 2 WEIGHTS = [1 / CONST_F,] for i in range(1, n - 1): c = (1 - sum(WEIGHTS[:i])) / CONST_F WEIGHTS.append(c) WEIGHTS.append(1 - sum(WEIGHTS)) return WEIGHTS def mood_examiner(): mood_list = [-1, 0, 1] res_mood = random.choices(mood_list, weights=[1/8, 5/8, 1/4], k=1)[0] return res_mood def conduct_exam(student, examiner, question: list): bank = question.copy() random.shuffle(bank) bank = bank[:3] answers_student = [] info = [] for question_word in bank: questions_examiner = [] words = question_word.split() questions_examiner.append(random.choice(words)) while random.random() < 1/3 and len(questions_examiner) < len(words): new_word = random.choice(words) if new_word not in questions_examiner: questions_examiner.append(new_word) weights = golden_ratio(len(words)) if student.sex == 'М': answer_student = random.choices(words, weights=weights, k=1)[0] else: answer_student = random.choices(words, weights=weights[::-1], k=1)[0] is_correct = answer_student in questions_examiner answers_student.append(is_correct) info.append({'question':question_word, 'is_correct':is_correct}) count_true = answers_student.count(True) count_false = answers_student.count(False) exam_result = '' mood = mood_examiner() match mood: case -1: exam_result = 'Провалил' case 0: if count_true >= count_false: exam_result = 'Сдал' else: exam_result = 'Провалил' case 1: exam_result = 'Сдал' exam_time = random.uniform(len(examiner.name) - 1, len(examiner.name) + 1) return exam_result, exam_time, info