A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© Sharpen 初级黑马   /  2018-10-7 21:12  /  1096 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

from random import *


def check(x, y):
    if ((x == 1 and y == 2)
            or (x == 2 and y == 3)
            or (x == 3 and y == 1)):
        print('You win!')
    else:
        print('You lose!')


running = True
while running:
    player = int(input('请输入您的出拳(石头:1,剪刀:2,布:3):'))
    computer = randint(1, 3)
    print('您的出拳: %d --电脑的出拳:%d' % (player, computer))

    if player == computer:
        print('您的出拳和电脑相同,请重新出拳!')
    else:
        running = False


check(player, computer)

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马