其他分享
首页 > 其他分享> > xingtai -猜拳和try一try

xingtai -猜拳和try一try

作者:互联网

import random
win = 0
lose = 0
draw = 0
xia = 0
for a in range(10):
    print("这是第"+str(a+1)+"局")
    computer = random.randint(1, 3)
    we = input("你在武汉出什么????")
    try:
        we = int(we)
        jieguo = computer - we
        if we > 3 or we < 1:
            print("瞎出会得肺炎")
            xia = xia + 1
        else:
            if jieguo == -1 or jieguo == 2:
                print("赢:武汉必胜")
                win = win + 1
            elif jieguo == -2 or jieguo == 1:
                print("输:捐点物资吧!!!")
                lose = lose + 1
            elif jieguo == 0:
                print("平:加油,武汉!!")
                draw = draw + 1
        # print(computer)
        if computer == 1:
            print("电脑出的是石头")
        elif computer == 2:
            print("电脑出的是布")
        elif computer == 3:
            print("电脑出的是剪刀")
        if we == 1:
            print("我出的是石头")
        elif we == 2:
            print("我出的是布")
        elif we == 3:
            print("我出的是剪刀")
    except:
        print("你真不认真治疗")
        xia = xia + 1

    print("----------------华丽的分割线--------------------------")

print("你一共赢了" + str(win) + "局")
print("你一共输了" + str(lose) + "局")
print("你一共平了" + str(draw) + "局")
print("你一共瞎出了" + str(xia) + "局")
少儿编程侯老师 发布了291 篇原创文章 · 获赞 18 · 访问量 1万+ 私信 关注

标签:xia,elif,猜拳,jieguo,try,computer,str,print,xingtai
来源: https://blog.csdn.net/houlaos/article/details/104201108