Python最简英语单词记忆游戏

Python最简英语单词记忆游戏

这里提供一个最简单的英语单词记忆游戏!

    from sprites import *              # 从精灵模块导入所有命令,包括了random,time等模块
    screen = Screen()
    screen.setup(480,360)

    words = {'hello':'你好','cat':'猫','dog':'狗','red':'红色'}
    s = Sprite()
    while True:
       word = random.choice(list(words.keys()))
       s.say(f'{word}是什么意思',1000,False)
       a = screen.textinput('输入框',f'{word}是什么意思?')
       if a == words[word]:
          s.say('你答对了')
       else:
          s.say('你答错了')
李兴球

李兴球的博客是Python创意编程原创博客

评论已关闭。