python猜拳游戏

猜拳游戏

"""
author:魏振东
data:2019.09.26
func:猜拳游戏
"""
import random
p_score = 0
c_score = 0
while True:
    computer = random.randint(1,3)
    player = int(input("1:石头,2:剪刀,3:布,4:退出\n"))

    if player == 1 and computer == 3 or player == 2 and computer == 1 or player == 3 and computer == 2:
        print('你赢了')
        p_score+=1
    elif computer == player:
        print('平局')
    elif player == 4:
        print('游戏退出!\n你的得分为:'+str(p_score)+'分\n电脑得分:'+str(c_score)+'分')
        break
    elif player == 1 or player == 2 or player == 3:
        print('电脑赢了')
        c_score += 1
    else:
        print('不要搞事情,请重新输入!')
        continue
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值