猫史档案馆


【Python作品分享】猜拳游戏【作品秀】

用户:sjkw看看sjkw看看查看:0 回复:1 评论:0 创建时间:2020-12-22T20:26:05


【作品展示】

center_image

 

【作品介绍】

石头,剪刀,布

 

【作品源代码】

import random


def game(score_a, score_b):

    print('当前比分:', score_a, ':', score_b)
    List = ['剪刀', '石头', '布']
    a = input('输入(剪刀,石头,布):')
    b = random.choice(List)
    print('你的输入:', a)
    print('电脑的输入:', b)
    if (a == b):
        print('打平了')
    elif (a == '石头' and b == '剪刀' or a == '剪刀' and b == '布' or a == '布' and b == '石头'):
        score_a += 1
        print('你赢了!当前比分:', score_a, ':', score_b)
    else:
        score_b += 1
        print('电脑赢了!当前比分:', score_a, ':', score_b)
    F = input('重新开始按1, 继续游戏按2,退出游戏按3:')
    if (F == '1'):
        print('-------------重新开始-------------')
        game(0, 0)
    elif (F == '2'):
        print('-------------继续游戏-------------')
        game(score_a, score_b)
    else:
        print('-------------游戏结束-------------')

game(0, 0)

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
雾蓁雾蓁

emotion_编程猫_点赞

点赞0


评论