欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

python背单词小程序

程序员文章站 2022-03-10 10:32:37
英语差就闲来无事用python写一个背单词的小程序,英语不好的博友们可以参考参考,哈哈~~~哈哈哈哈哈程序代码:import random as t#创建单词序列words=("easy","difficult","answer","continue")zi=("容易","困难","回答","继续")hanzi={ "easy":"容易", "difficult":"困难","answer":"回答", "continue":"继续","blue":"蓝色"}yin={"容易":"easy",...

英语差就闲来无事用python写一个背单词的小程序,博友们可以参考参考

程序代码:

import random as t #创建单词序列 words=("easy","difficult","answer","continue") zi=("容易","困难","回答","继续") hanzi={ "easy":"容易", "difficult":"困难","answer":"回答", "continue":"继续","blue":"蓝色"} yin={"容易":"easy","困难":"difficult","回答":"answer","继续":"continue","蓝色":"blue"} def jiemian(): print("""
                     欢迎来到背单词
        根据English回答汉语或者根据汉语回答English
        -------------------------------------------
                    1.English——>汉语
                    
                    2.汉语——>English
                    
                    3.单词列表
                    
                    4.退出系统
""") #######Zhang######  English——>汉语   ################################ def yyihan(): n=0 m=0 su=0 iscontinue="y" while iscontinue=="y" or iscontinue=="Y": word=t.choice(words) print("随机生成在单词:") print(">------>   "+word) guess=input("\n输入汉语: ").strip()# 防止用户误操作录入空白 while guess!=hanzi[word]: print("对不起,不正确。") n=n+1 print('\n——>正确率:%.2f'%(m/(n+m))) guess=input("继续输入:").strip() if guess==hanzi[word]: print("真棒!答对了!!") m=m+1 print('\n——>正确率:%.2f'%(m/(n+m))) iscontinue=input("\nn\是否继续(Y/N):") ###############  汉语——>English   #########wei#################### def hanyiy(): n=0; m=0; su=0; iscontinue="y" while iscontinue=="y" or iscontinue=="Y": hz=t.choice(zi) print("随机生成在汉语:") print(">------>   "+hz) guess=input("\n输入Ehglish: ").strip() while guess!=yin[hz]: print("对不起,不正确。") n=n+1 print('\n——>正确率:%.2f'%(m/(n+m))) guess=input("继续输入:").strip() if guess==yin[hz]: print("真棒!答对了!!") m=m+1 print('\n——>正确率:%.2f'%(m/(n+m))) iscontinue=input("\nn\是否继续(Y/N):") ####bu########################################################## def lib(): print("************************") print("\n") for i in range (len(words)): print(words[i],"   ",zi[i],"\n") print("\n") print("************************") a=input("输入 1 背诵单词结束——>: ") ################################################################### while True: jiemian() a=int(input("\n\n\n\选择需要进行的操作(1、2、3、4):")) if(a==1): yyihan() elif a==2: hanyiy() elif a==3: lib() elif a==4: exit() else: print("输入格式错误,重新输入!!") 

本文地址:https://blog.csdn.net/qq_44859533/article/details/108833713

相关标签: Python 背单词