点击 "下一步" 开始执行代码。
1import random
2
3z={'男孩': 'boy', '女孩': 'girl', '零': 'zero', '一': 'one',
4 '二': 'two', '三': 'three', '四': 'four', '五': 'five',
5 '六': 'six', '七': 'seven', '八': 'eight', '九': 'nine',
6 '电话': 'phone', '数字': 'number', '它': 'it',
7 'It is缩写': "It's", '卡 卡片': 'card', '家,家庭': 'family',
8 '这,这个': 'this', '铅笔': 'pencil', '钢笔': 'pen', '书':
9 'book', '橡皮,黑板擦': 'eraser', '尺,直尺': 'ruler',
10 '箱,盒': 'case', '双肩背包': 'backpack', '词典,字典': 'dictionary',
11 '那,那个': 'that', '是': 'yes', '不是': 'no',
12 '原谅,宽恕': 'excuse', '感谢': 'thank', '好,不错': 'OK',
13 '在里面': 'in', '英语,英文': 'English', '一个': 'a',
14 '多么,怎样(表程度)': 'how', '做,干': 'do', '拼写': 'spell',
15 '棒球': 'baseball', '手表': 'watch', '电脑,电子计算机': 'computer',
16 '游戏': 'game', '钥匙': 'key', '笔记本': 'notebook', '戒指': 'ring',
17 '打电话': 'call', '在……附近,以': 'at', '在……里面': 'in',
18 '人,物(表示特指,定冠词)': 'the', '遗失': 'lost', '找回': 'found'}
19item=list(z.keys()) # 取字典的键
20while 1:
21
22
23 wordkey=random.choice(item)
24 print("\n",wordkey)
25 ans=input("请默写该单词的英文:")
26
27 if ans==z[wordkey]:
28 print("回答正确")
29 else:
30 print("回答错误,正确答案是:",z[wordkey])
31 cont=input("按任意键继续,退出请按N:")
32 if cont.upper()=="N":
33 print("加油吧少年!")
34 break
字典 z (Dictionary)
列表 item (List - 所有的键)
等待初始化...
wordkey
-
ans (你的回答)
-
cont (是否继续)
-
Microsoft Windows [版本 10.0...] (c) Microsoft Corporation。保留所有权利。 C:\Users\Python> python quiz.py