知識
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價值,我們在追求其視覺表現(xiàn)的同時,更側(cè)重于功能的便捷,營銷的便利,運營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序為后期升級提供便捷的支持!
您當(dāng)前位置>首頁 » 新聞資訊 » 小程序相關(guān) >
Python實現(xiàn)背單詞小程序
發(fā)表時間:2020-10-19
發(fā)布人:葵宇科技
瀏覽次數(shù):117
程序還有很多的不足,界面也比較垃圾,功能也不是很多,但畢竟也寫了幾天,克服了許多困難才寫出來的,還是挺有成就感的。現(xiàn)在單詞只有兩個,可以在English和Chinese兩個字典中添加單詞
import random
English={"China":"中國","blue":"藍(lán)色"}
Chinese={"中國":"China","藍(lán)色":"blue"}
def interface():
print(
"""
歡迎來到英語之家
請根據(jù)自己的需要選擇下面功能
********************************************************************************
*1.英語查漢語
*2.漢語查英語
*3.隨機測試
*4.退出系統(tǒng)
"""
)
def Test():
print(
"""
請選擇測試的方式
**1.亂序猜單詞
**2.漢語猜單詞
**3.返回上一級
"""
)
def English_Chinese():
find="y"
while find=='Y' or find=='y':
a=input("請輸入需要查找的單詞") #輸入一個單詞
b=English.get(a) #將字典中鍵值a對應(yīng)的值存到b中,如果沒有找到b為None
if b==None:
print("查找的單詞在字典中不存在")
else:
print(a,"單詞的中文意思為>>",b)
while find=="Y" or find=="y" or find=="N" or find=="n":
find=input("是否繼續(xù):是(Y/y)/t否(N/n)>>")
if find!="Y" and find!="y" and find!="N" and find!="n":
print("輸入不符合規(guī)范,請重新輸入。。。。")
else: break;
def Chinese_English():
find='y'
while find=='y' or find=='Y':
a=input("請輸入需要查找的中文")
b=Chinese.get(a) #將字典中鍵值a對應(yīng)的值存到b中,如果沒有找到b為None
if b==None:
print("查找的單詞在字典中不存在")
else:
print(a,"單詞的英文意思為>>",b)
while find=="Y" or find=="y" or find=="N" or find=="n":
find=input("是否繼續(xù):是(Y/y)/t否(N/n)>>")
if find!="Y" and find!="y" and find!="N" and find!="n":
print("輸入不符合規(guī)范,請重新輸入。。。。")
else: break;
def Word_Test1():
find="y"
a=0
b=0
while find=='y' or find=='Y':
word=random.sample(English.keys(),1)
word=str(word)
word=word[2:-2]
correct=word
#print(type(correct))
#print(correct,word)
kong=''
while word:
w=random.randrange(len(word))
kong+=word[w]
word=word[:w]+word[(w+1):]
#print(w)
print("亂序后的單詞:",kong)
guess=input("輸入你認(rèn)為的單詞:")
while guess!=correct and guess!=" ":
print("回答錯誤,請仔細(xì)想想,輸入空格代表放棄回答")
a+=1
print("當(dāng)前正確率為:",(int)(b/(b+a)*10000)/100,"%")
guess=input("再次輸入:")
if guess==correct:
print("答對了,繼續(xù)加油")
b=b+1
print("當(dāng)前正確率為:",(int)(b/(b+a)*10000)/100,"%")
elif guess==" ":
print("答案是>>",correct)
print("當(dāng)前正確率為:",(int)(b/(b+a)*10000)/100,"%")
while find=="Y" or find=="y" or find=="N" or find=="n":
find=input("是否繼續(xù):是(Y/y)/t否(N/n)>>")
if find!="Y" and find!="y" and find!="N" and find!="n":
print("輸入不符合規(guī)范,請重新輸入。。。。")
else: break;
def Word_Test2():
find="y"
a=0
b=0
while find=='y' or find=='Y':
word=random.sample(Chinese.keys(),1)
word=str(word)[2:-2]
print("請輸出漢語",word,"對應(yīng)的英文單詞")
guess=input("輸入你認(rèn)為的單詞>>")
correct=Chinese.get(word)
#print(correct)
while guess!=correct and guess!=" ":
print("回答錯誤,請仔細(xì)想想,輸入空格代表放棄回答")
a+=1
print("當(dāng)前正確率為:",(int)(b/(b+a)*10000)/100,"%")
guess=input("再次輸入:")
if guess==correct:
print("答對了,繼續(xù)加油")
b=b+1
print("當(dāng)前正確率為:",(int)(b/(b+a)*10000)/100,"%")
elif guess==" ":
print("答案是>>",correct)
print("當(dāng)前正確率為:",(int)(b/(b+a)*10000)/100,"%")
while find=="Y" or find=="y" or find=="N" or find=="n":
find=input("是否繼續(xù):是(Y/y)/t否(N/n)>>")
if find!="Y" and find!="y" and find!="N" and find!="n":
print("輸入不符合規(guī)范,請重新輸入。。。。")
else: break;
while True:
interface()
a=int(input("***請選擇你需要的功能>>"))
if a==1:
English_Chinese()
elif a==2:
Chinese_English()
elif a==3:
while True:
Test()
b=int(input("***請選擇你需要的功能>>"))
if b==1:
Word_Test1()
elif b==2:
Word_Test2()
elif b==3:
break
else:
print("輸入有誤!!!請從新選擇!!!")
elif a==4:
exit(0)
else:
print("輸入有誤!!!請從新選擇!!!")
相關(guān)案例查看更多
相關(guān)閱讀
- 云南網(wǎng)站建設(shè)快速優(yōu)化
- 云南省建設(shè)廳網(wǎng)站官網(wǎng)
- 云南網(wǎng)站建設(shè)方法
- 模版信息
- 云南小程序代建
- 云南網(wǎng)站建設(shè)專家
- 云南網(wǎng)站建設(shè)高手
- 云南省建設(shè)廳官方網(wǎng)站
- 云南網(wǎng)站建設(shè)靠譜公司
- 云南手機網(wǎng)站建設(shè)
- 云南網(wǎng)站建設(shè)列表網(wǎng)
- 云南網(wǎng)站建設(shè)哪家強
- vue開發(fā)小程序
- 云南網(wǎng)站建設(shè)公司排名
- 云南做軟件
- 云南網(wǎng)站建設(shè)電話
- 云南網(wǎng)絡(luò)營銷顧問
- 微信小程序
- 小程序開發(fā)排名前十名
- 云南企業(yè)網(wǎng)站
- 安家微信小程序
- 生成海報
- 排名
- 云南網(wǎng)站建設(shè)首選
- 小程序用戶登錄
- 報廢車管理系統(tǒng)
- 百度小程序開發(fā)
- 網(wǎng)站維護
- 云南微信小程序開發(fā)
- 網(wǎng)站沒排名