main.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:flashcard 作者: sotetsuk 项目源码 文件源码
def run(flashcard: Flashcard, hint_rate=None):
    n = len(flashcard)
    num_collect = 0
    for i, card in enumerate(flashcard):
        problem = card[0]
        expected = card[1]

        print("# {:02d}".format(i + 1), problem)

        if hint_rate is not None:
            print(colored("hint", "blue"), hint(expected, hint_rate))

        ans = input(">>>> ")

        if expected == ans.strip():
            num_collect += 1
            print(colored('GOOD', 'green'), colored(expected, "green"))
        else:
            expected_with_mistake, ans_with_mistake = get_diff_with_color(expected, ans)
            print(colored('MISS', 'red'), expected_with_mistake)
            print('    ', ans_with_mistake)

        print("*" * 100)

    print("{}/{}".format(num_collect, n))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号