鱼C论坛

 找回密码
 立即注册
查看: 2861|回复: 3

[作品展示] WYH运算练习器

[复制链接]
发表于 2023-1-13 14:12:18 | 显示全部楼层 |阅读模式

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

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

x
马上回老家啦!于是给亲戚小孩写个“帮助”练习运算的东西(翻译:我看不得别人轻松
bug比较多(例如:减法和除法会出小数)
import easygui as eg
import random as rd

yunsuan = eg.buttonbox('你想练习哪种运算', choices=['加法', '减法', '乘法', '除法'])
if yunsuan == '加法':
    number = int(eg.enterbox('你希望加数的范围是从零到几'))
    while True:
        num1 = rd.randint(0, number + 1)
        num2 = rd.randint(0, number + 1)
        reply = eg.enterbox('答案是几?', f'{num1}+{num2}是多少')
        if int(reply) == num1 + num2:
            eg.msgbox('答对了!')
        else:
            eg.msgbox('答错啦!再接再厉!')
elif yunsuan == '减法':
    number = int(eg.enterbox('你希望减数与被减数的范围是从零到几'))
    while True:
        num1 = rd.randint(0, number + 1)
        num2 = rd.randint(0, number + 1)
        reply = eg.enterbox('答案是几?', f'{num1}-{num2}是多少')
        if int(reply) == num1 - num2:
            eg.msgbox('答对了!')
        else:
            eg.msgbox('答错啦!再接再厉!')
elif yunsuan == '乘法':
    number = int(eg.enterbox('你希望乘数的范围是从零到几'))
    while True:
        num1 = rd.randint(0, number + 1)
        num2 = rd.randint(0, number + 1)
        reply = eg.enterbox('答案是几?', f'{num1}×{num2}是多少')
        if int(reply) == num1 * num2:
            eg.msgbox('答对了!')
        else:
            eg.msgbox('答错啦!再接再厉!')
elif yunsuan == '除法':
    number = int(eg.enterbox('你希望除数与被除数的范围是从零到几'))
    while True:
        num1 = rd.randint(0, number + 1)
        num2 = rd.randint(0, number + 1)
        reply = eg.enterbox('答案是几?', f'{num1}÷{num2}是多少')
        if int(reply) == num1 / num2:
            eg.msgbox('答对了!')
        else:
            eg.msgbox('答错啦!再接再厉!')
写的不好,不求评分,但求评论!

不知道为什么今天的帖子老发布出去,这是第三遍尝试了】

评分

参与人数 1荣誉 +1 鱼币 +1 收起 理由
liuhongrun2022 + 1 + 1

查看全部评分

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

使用道具 举报

发表于 2023-1-14 10:39:57 | 显示全部楼层

加油!!!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2023-1-14 10:41:06 | 显示全部楼层
不知道为什么今天的帖子老发不出去

因为你发帖子太频繁了
你等待审核通过就行了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-1-14 14:35:17 | 显示全部楼层
liuhongrun2022 发表于 2023-1-14 10:41
因为你发帖子太频繁了
你等待审核通过就行了

知道力!谢谢啦
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-24 23:29

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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