猫史档案馆


python做的计算机

用户:一条不是很咸的咸鱼一条不是很咸的咸鱼查看:0 回复:0 评论:0 创建时间:2023-06-10T19:36:46


import easygui


a = 0
s = 0
while True:
    try:
        e1 = int(easygui.enterbox("请输入第一个数字:"))
        e2 = int(easygui.enterbox("请输入第二个数字:"))
    except (Exception):
        break
    else:
        c1 = easygui.buttonbox("请选择运算符:",choices=["+","-","*","/"])
        if c1 == "+":
            a = e1 + e2
        elif c1 == "-":
            a = e1 - e2
        elif c1 == "*":
            a = e1 * e2
        elif c1 == "/":
            a = e1 / e2
        if s == 1:
            c1 = easygui.buttonbox("请选择几个数的运算符:", choices=["+", "-", "*", "/"])
            if c1 == "+":
                a += e1 + e2
            elif c1 == "-":
                a += e1 - e2
            elif c1 == "*":
                a += e1 * e2
            elif c1 == "/":
                a += e1 / e2
                
        c = easygui.ynbox("您想要继续吗?")
        if c == True:
            s = 1
        else:
            break
easygui.msgbox("最后的计算结果是:"+str(a))


回复

上一页1 页 / 共 0下一页