Created
May 12, 2018 08:20
-
-
Save KojiAomatsu/f4210a3122520306475571bd6afe84fe to your computer and use it in GitHub Desktop.
Anki card example
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
import random | |
def play(): | |
print("暗記ゲームにようこそ。半角数字でモードを選んでな") | |
print("0: 数字から累乗数, 1: 累乗数から数字") | |
mode = input() | |
if mode != "0" and mode != "1": | |
print("変な入力あったから終わりや") | |
return | |
mode = int(mode) | |
print("何乗の累乗数を問題にしたい?10以下の数字で答えてな") | |
ind = input() | |
if not ind.isdigit(): | |
print("数字入力してな。終わりや") | |
return | |
ind = int(ind) | |
if ind > 10: | |
print("流石に無茶やな。終わりや") | |
return | |
print("範囲は2から何までにする?10以上1000以下にしてな") | |
ran = input() | |
if not ran.isdigit(): | |
print("数字入力してな。終わりや") | |
return | |
ran = int(ran) | |
if ran > 1000 or ran < 9: | |
print("範囲内で答えろよ。終わりや") | |
return | |
li = [] | |
for i in range(2, ran + 1): | |
li.append([i, i**ind]) | |
print("\n始めるで!終わる時は「p」って打ち込んでな") | |
if mode == 0: | |
print("数字から累乗数を求めるんやで\n") | |
else: | |
print("累乗数から数字を求めるんやで\n") | |
flag = True | |
while flag: | |
target = random.choice(li) | |
print("問題: ",target[mode]) | |
dummy = input() | |
if dummy == "p": | |
flag = False | |
break | |
print("答え: ",target[1 - mode],"\n") | |
dummy2 = input() | |
if dummy2 == "p": | |
flag = False | |
print("ありがとうな。また遊んでな") | |
if __name__ == "__main__": | |
play() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment