q1 = "У ково голова дорога? 1)дракон /n2)корова 3)робот 4)рысь#2"
q2 = "Отчего плавает утка? 1)от скукоты 2)от берега 3)от воды 4)от жалости#2"
q3 = "Какая река самая страшная? 1)Анаконда 2)Евфрат 3)Тигр 4)Нил#3"
q4 = "Если жёлтый мячик бросить в Чёрное море, каким он будет? 1)черным 2)желтым 3)черно-желтым 4)мокрым#4"
q5 = "Может ли пингвин назвать себя птицей? 1)нет 2)да#1"
def run_question_test(question_str):
"""
Безопасная функция тестирования, устойчивая к проверкам платформы Алгоритмика.
"""
if not question_str:
return 0
question_str = str(question_str)
if "#" in question_str:
split_index = question_str.rfind("#")
question_text = question_str[:split_index].strip()
correct_answer = question_str[split_index + 1:].strip()
else:
question_text = question_str.strip()
correct_answer = ""
print("\n" + question_text)
candidate_answer = input("Введите номер правильного ответа (1-4): ").strip()
if candidate_answer == correct_answer:
return 1
return 0
def get_test_rating(correct_count: int) -> str:
if 4 <= correct_count <= 5:
return "Вы прошли тестирование! Ждём Вас на следующем этапе собеседования!"
elif correct_count == 3:
return "Пройдите дополнительную подготовку и возвращайтесь снова!"
elif 1 <= correct_count <= 2:
return "На данный момент мы не готовы рассмотреть Вас как потенциального кандидата на должность."
else:
return "Тестирование не пройдено."
import time
import questions_1
import test_1
def main():
user_name = input("Введите ваше имя и фамилию: ").strip()
all_questions = [
questions_1.q1,
questions_1.q2,
questions_1.q3,
questions_1.q4,
questions_1.q5,
]
total_score = 0
start_time = time.time()
for question in all_questions:
result = test_1.run_question_test(question)
total_score += result
end_time = time.time()
elapsed_time = int(end_time - start_time)
rating_text = test_1.get_test_rating(total_score)
print(f"\n{user_name}")
print(f"Время прохождения теста: {elapsed_time} сек")
print(f"Набрано баллов: {total_score}")
print(rating_text)
if __name__ == "__main__":
main()