Skip to content

Instantly share code, notes, and snippets.

@stonecharioteer
Created September 30, 2018 16:38
Show Gist options
  • Save stonecharioteer/47746c68ee32c3ae00f4fee61f8b12a2 to your computer and use it in GitHub Desktop.
Save stonecharioteer/47746c68ee32c3ae00f4fee61f8b12a2 to your computer and use it in GitHub Desktop.
Start the hiragana quiz.
def start_quiz():
"""Starts the epaperhat quiz."""
import random
hiragana = get_hiragana()
points = 0
total = 0
while True:
total+=1
hiragana_to_test = random.choice(list(hiragana.keys()))
correct_kana = hiragana[hiragana_to_test]
other_options = [x for x in hiragana.values() if x != correct_kana]
other_options = random.sample(other_options, 3)
other_options.append(correct_kana)
random.shuffle(other_options)
answer = test_romaji_hiragana(hiragana_to_test, other_options)
if answer == correct_kana:
points+=1
success=True
comment = None
else:
success=False
comment = u"{}: {}".format(hiragana_to_test, correct_kana)
print_result(points, total, success, comment)
reply = get_input(wait=100)
if reply == 4:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment