python背单词小步调

python背单词小步调

转发觉得博友的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("输出方法缺点,从新输出!!")

分享到 :
相关推荐

Leave a Reply

Your email address will not be published. Required fields are marked *