马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
废话不多说,直接放代码: import random
word_list = ["nice","good","wow","cow","car","jar","mud","you","human","wine"] #可自行添加
mean_list = ["棒的","好的","表示吃惊","奶牛","车","坛子","泥土","你","人类","红酒"] #可自行添加
heavy = 10
heavy_list = [heavy for i in range(len(word_list))] #默认每个要背出的次数列表
now_heavy = 9
now_heavy_list = [now_heavy for i in range(len(word_list))] #每个已背出的次数列表
finish = [True for each in zip(now_heavy_list,heavy_list) if each[0] == each[1]]
finish = True if len(finish) == len(word_list) else False #只要结束的项与总共要结束的量相同,就代表全都结束了,就算结束了
while not finish: #如果没有结束背诵任务
i_list = random.sample(range(len(word_list)),len(word_list)) #不重复的随机抽选要提问的单词的先后顺序
for i in i_list:
ranswer = mean_list[i]
guess = word_list[i]
number1 = random.randint(0,len(mean_list) - 1)
number2 = random.randint(1,(len(mean_list) - (number1)))
button = [ranswer,mean_list[number1 - number2],mean_list[number1]]
button_list = random.sample(range(0,3),3)
button_dict = {i[1]:button[int(i[0])] for i in zip([str(each) for each in button_list],["A","B","C"])}
for each in button_dict.items():
print(each[0],".",each[1])
answer = input(f"请选择单词 {guess} 的意思在上方选项中的最贴切的一项:")
while answer.isspace() or answer == "":
answer = input("请选择正确的一项:")
answer = answer.strip()
if button_dict.get(answer) == ranswer: #如果猜对
now_heavy_list[i] += 1
print("答对了!")
else: #如果没猜对
heavy_list[i] += 1
print("答错了!")
for i in range(70):
print(f"{'|':^156}")
print()
finish = [True for each in zip(now_heavy_list,heavy_list) if each[0] == each[1]]
finish = True if len(finish) == len(word_list) else False
print("你已成功记下了这些单词:{}!".format(",".join(word_list)))
这段代码还没有优化! 所以我会在下一个版本中优化的!
制作不易,喜欢的话,就评个分吧!
最后,祝大家新年快乐,寒假作业不被老师检查...... |