猫史档案馆


【Python作品分享】石头剪刀布

用户:友爱的乌力MOWF友爱的乌力MOWF查看:0 回复:0 评论:0 创建时间:2023-06-09T17:12:02


【作品展示】

center_image

 

【作品介绍】

hello

 

【作品源代码】

import time
import random


for __count in range(400):
    a = input('石头,剪刀,还是布')
    if (a == '石头'):
        print('你出了石头')
        shshshi = 1
    elif (a == '剪刀'):
        print('你出了剪刀')
        shshshi = 2
    else:
        print('你出了布')
        shshshi = 3
    print('处理中......')
    time.sleep(1)
    shshsh = random.randint(1, 3)
    if (shshsh == '1'):
        print('电脑出了石头')
    elif (shshsh == '2'):
        print('电脑出了剪刀')
    else:
        print('电脑出了布')
    if (shshsh == 1 and shshshi == 1):
        print('平局了,电脑出了石头,你也出了石头')
    elif (shshsh == 1 and shshshi == 2):
        print('你输了,电脑出了石头,你出了剪刀')
    elif (shshsh == 1 and shshshi == 3):
        print('你赢了,电脑出了石头,你出了布')
    elif (shshsh == 2 and shshshi == 1):
        print('你赢了,电脑出了剪刀,你出了石头')
    elif (shshsh == 2 and shshshi == 2):
        print('平局了,电脑出了剪刀,你也出了剪刀')
    elif (shshsh == 2 and shshshi == 3):
        print('你输了,电脑出了剪刀,你出了布')
    elif (shshsh == 3 and shshshi == 1):
        print('你输了,电脑出了布,你出了石头')
    elif (shshsh == 3 and shshshi == 2):
        print('你赢了,电脑出了布,你出了剪刀')
    else:
        print('平局了,电脑出了布,你也出了布')
    if (str(input('是否结束')) == str('是')):
        break
    else:
        pass

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页