Created
September 30, 2018 16:38
-
-
Save stonecharioteer/47746c68ee32c3ae00f4fee61f8b12a2 to your computer and use it in GitHub Desktop.
Start the hiragana quiz.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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