Last active
April 15, 2022 00:47
-
-
Save guidanoli/48129f1a936f8a0962a3e6e524f51091 to your computer and use it in GitHub Desktop.
Exercise Hiragana
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
#!/usr/bin/env python3 | |
import random | |
from colorama import Fore | |
hiraganas = { | |
"あ": "a", | |
"い": "i", | |
"う": "u", | |
"え": "e", | |
"お": "o", | |
"か": "ka", | |
"き": "ki", | |
"く": "ku", | |
"け": "ke", | |
"こ": "ko", | |
"さ": "sa", | |
"し": "shi", | |
"す": "su", | |
"せ": "se", | |
"そ": "so", | |
"た": "ta", | |
"ち": "chi", | |
"つ": "tsu", | |
"て": "te", | |
"と": "to", | |
"な": "na", | |
"に": "ni", | |
"ぬ": "nu", | |
"ね": "ne", | |
"の": "no", | |
"は": "ha", | |
"ひ": "hi", | |
"ふ": "fu", | |
"へ": "he", | |
"ほ": "ho", | |
"ま": "ma", | |
"み": "mi", | |
"む": "mu", | |
"め": "me", | |
"も": "mo", | |
"や": "ya", | |
"ゆ": "yu", | |
"よ": "yo", | |
"ら": "ra", | |
"り": "ri", | |
"る": "ru", | |
"れ": "re", | |
"ろ": "ro", | |
"わ": "wa", | |
"を": "wo", | |
"ん": "n", | |
} | |
random_hiraganas = list(hiraganas.keys()) | |
random.shuffle(random_hiraganas) | |
answers = {} | |
for hiragana in random_hiraganas: | |
answers[hiragana] = input('{}? '.format(hiragana)) | |
print() | |
print('Results') | |
print('=======') | |
for hiragana, romanji in hiraganas.items(): | |
answer = answers[hiragana] | |
if answer == romanji: | |
print(Fore.GREEN + '{} -- {}'.format(hiragana, romanji)) | |
elif answer == "": | |
print(Fore.RED + '{} -- {}'.format(hiragana, romanji)) | |
else: | |
print(Fore.YELLOW + '{} -- {} (guessed "{}")'.format(hiragana, | |
romanji, | |
answer)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment