猫史档案馆


【Python作品分享】100以内加减法练习【作品秀】

用户:星火_返场星火_返场查看:0 回复:1 评论:0 创建时间:2021-02-05T11:34:29


【作品展示】

center_image

 

【作品介绍】

数学不好的多练练

康康你的口算怎么样

 

【作品源代码】

import random
c = 0
print("开始")
while True:
    print("------------")
    if random.randint(1,2) == 1:
        d = "+"
    else:
        d = "-"
    a, b = random.randint(1, 100), random.randint(1, 100)
    if d == "+":
        print("{}+{}=".format(a,b))
        if int(input()) == a+b:
            print("算对了")
            c += 1
            print(c)
        else:
            print("算错了")
            break
    else:
        print("{}-{}=".format(a, b))
        if int(input()) == a-b:
            print("算对了")
            c += 1
            print(c)
        else:
            print("算错了")
            break

print("一共算对了{}道题".format(c))
print("恭喜恭喜恭喜你呀")
print("恭喜恭喜恭喜你!")

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
星火_返场星火_返场

emotion_雷电猴_摇椅子

点赞0


评论