鱼C论坛

 找回密码
 立即注册
查看: 1493|回复: 2

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

[复制链接]
发表于 2020-5-10 19:32:22 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

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

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[button][1]
    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[button][0]
        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[each])
        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[each_fruit],ok_button="下一个",image=Fruit[each_fruit])

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

    if button == "Food(食物)":
        for each_food in Food:
            g.msgbox(msg3[each_food],ok_button="下一个",image=Food[each_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(水果)":[f,Fruit],"Animal(动物)":[a,Animal],"Food(食物)":[d,Food]}                        

study(name)                        
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-5-10 19:54:38 | 显示全部楼层
把图片打包一下
用tkinter做会更华丽
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-11 11:14:56 | 显示全部楼层
我还不知道tkinter是啥,对哦,图片都存在我的电脑里,T_T
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-12-22 13:48

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表