import threading
import time
import random
RUSSIAN_WORDS = ['песок', 'доверие', 'дикий', 'расти', 'древний', 'пустиня', 'пыль']
ENGLISH_WORDS = ["sand", "dust", "trust", "wild", "grow", "ancient", "desert"]
def get_answer():
global answer
answer = None
answer = input("Введите слово: ")
test_version = int(input('Введите версию теста: '))
if test_version == 1:
random_words = random.sample(RUSSIAN_WORDS, k=4)
for word in random_words:
total_seconds = 0
print(word)
input_thread = threading.Thread(target=get_answer)
input_thread.start()
while total_seconds < 10:
if answer is None:
time.sleep(1)
total_seconds += 1
else:
break
if answer is not None:
if answer in ENGLISH_WORDS:
print('Правильно!')
else:
print('Неправильно!')
else:
print("Вы не успели дать ответ!")
elif test_version == 2:
random_words = random.sample(ENGLISH_WORDS, k=4)
for word in random_words:
total_seconds = 0
print(word)
input_thread = threading.Thread(target=get_answer)
input_thread.start()
while total_seconds < 10:
if answer is None:
time.sleep(1)
total_seconds += 1
else:
break
if answer is not None:
if answer in RUSSIAN_WORDS:
print('Правильно!')
else:
print('Неправильно!')
else:
print("Вы не успели дать ответ!")