sunnyLHS 发表于 2020-5-10 19:32:22

第38课作业最后一题之基本英语单词的学习

以下是我自己制作的一个简易版的学习几个基本英语单词的玩意儿,要是能发音就更完美了,这个暂时我还不会.然后我参照小甲鱼的封装模块,我也封装了一下,是不是看上去高大上一点了

import easygui as g
import os
import random as r

def result(number):
    if number == 8:
      button = g.buttonbox("恭喜你全部答对啦!",choices=("继续学习","退出"),image="学习.gif")
      if button == "继续学习":
            study(name)
    else:
      button = g.buttonbox("还需要继续努力哦!",choices=("继续学习","退出"),image="学习.gif")
      if button == "继续学习":
            study(name)

def choice(button):
    os.chdir("C:\\Users\\Administration\\Desktop\\Python文件下载\\gif图片")
    list_keys = []
    kind = dict1
    for i in kind.keys():
      list_keys.append(i)
    list_r = r.sample(list_keys,len(list_keys))
    count = 8
    for each in list_r:
      choice_error = dict1
      A = r.choice(choice_error)
      choice_error.remove(A)
      B = r.choice(choice_error)
      C = each
      choices = r.sample((A,B,C),k=3)
      answer = g.buttonbox(choices=choices,image=kind)
      if answer != each:
            g.msgbox(("答错啦!正确答案是:",each),ok_button="继续")
            count -= 1
    result(count)


def test(button):
   
    g.msgbox("现在我们要开始测试咯![认真仔细,沉着冷静]")
    if button == "Fruit(水果)":
      choice(button)
                           
    if button == "Animal(动物)":
      choice(button)

    if button == "Food(食物)":
       choice(button)


def study(name):
    msg = "你希望学习一些什么类型的单词呢?"
    title = "趣味英语"
    choices=["Fruit(水果)","Animal(动物)","Food(食物)"]
    button = g.buttonbox(msg,title,choices)
   
    os.chdir("C:\\Users\\Administration\\Desktop\\Python文件下载\\图片")

    g.msgbox("Are you ready?",ok_button="Yes")

    if button == "Fruit(水果)":
      for each_fruit in Fruit:
            g.msgbox(msg=msg1,ok_button="下一个",image=Fruit)

    if button == "Animal(动物)":
      for each_animal in Animal:
            g.msgbox(msg=msg2,ok_button="下一个",image=Animal)

    if button == "Food(食物)":
      for each_food in Food:
            g.msgbox(msg3,ok_button="下一个",image=Food)

    msg = button + "部分已经学完啦!想要进行测试吗?"
    a = ["好的","不,我要继续学习"]
    order = g.buttonbox(msg,title="",choices=a)
    if order == "不,我要继续学习":
      study(name)
    else:
      test(button)

      
      

msg = "请输入你的名字:"
name = g.enterbox(msg)
msg = "%s,让我们来学习一些基础的英语单词吧!"%name
title = "趣味英语"
ok_button = "我非常乐意!"
g.msgbox(msg,title,ok_button)



Fruit = {"banana":"香蕉.gif","apple":"苹果.gif","orange":"橙子.gif","pear":"梨子.gif","peach":"桃子.gif","grape":"葡萄.gif","pinapple":"菠萝.gif","watermanlen":"西瓜.gif"}
Animal = {"monkey":"猴子.gif","panda":"熊猫.gif","penguin":"企鹅.gif","giraffe":"长颈鹿.gif","elephant":"大象.gif","tiger":"老虎.gif","lion":"狮子.gif","swan":"天鹅.gif"}
Food = {"dumplings":"饺子.gif","noodle":"面条.gif","cake":"蛋糕.gif","sandwich":"三明治.gif","bread":"面包.gif","rice":"米饭.gif","soup":"汤.gif","salad":"沙拉.gif"}

msg1 = {"banana":"香蕉","apple":"苹果","orange":"橙子","pear":"梨子","peach":"桃子","grape":"葡萄","pinapple":"菠萝","watermanlen":"西瓜"}
msg2 = {"monkey":"猴子","panda":"熊猫","penguin":"企鹅","giraffe":"长颈鹿","elephant":"大象","tiger":"老虎","lion":"狮子","swan":"天鹅"}
msg3 = {"dumplings":"饺子","noodle":"面条","cake":"蛋糕","sandwich":"三明治","bread":"面包","rice":"米饭","soup":"汤","salad":"沙拉"}               

f = ["tomato","shanddock","lemon","cherry","tangerine","coconut","mango","strawberry","bluberry","pawpaaw","apricot","jackfruit"]
d = ["congee","pizza","steak","fillet","sausage","butter","rape","cookies","hamburger","cheese","yam","daylily","flour","oat","corn"]
a = ["allow","sparrow","beetle","crane","peacock","rat","deer","zebra","horse","turkey","pigeon","snake","eagle","dragen","lizard"]

dict1 = {"Fruit(水果)":,"Animal(动物)":,"Food(食物)":}                        

study(name)                        

wuqramy 发表于 2020-5-10 19:54:38

把图片打包一下
用tkinter做会更华丽

sunnyLHS 发表于 2020-5-11 11:14:56

我还不知道tkinter是啥,对哦,图片都存在我的电脑里,T_T
页: [1]
查看完整版本: 第38课作业最后一题之基本英语单词的学习