猫史档案馆


【Python作品分享】剪刀石头布(上)【教程贴】

用户:春娇Vicky春娇Vicky查看:0 回复:1 评论:0 创建时间:2021-07-01T16:23:39


【作品展示】

center_image

 

【作品介绍】

剪刀石头布上一部分已经带给大家楼~

 

【作品源代码】

import random


def runGame():

    playGame = 1
    while (playGame == 1):
        print('1是拳头,2是剪刀,3是布,exit退出游戏')
        play = ['拳头', '剪刀 ', '布', '退出']
        computer = ['拳头', '剪刀 ', '布', '退出']
        print(input('你要出什么鸭'))
        print('电脑出了', computer[random.randint(0, 2)])
        if (play == 1 and computer == 0):
            print('you WIN!')
        elif (play == 1 and computer == 1):
            print('平局')
        else:
            print('you lose')
        if (play == 1 and computer == 2):
            print('you WIN!')
        elif (play == 2 and computer == 2):
            print('平局')
        else:
            print('you lose')
            
runGame()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
BLUEGEUSTBLUEGEUST

就一个函数?

 

点赞0


评论