用户:
务实的呆鲤鱼izou查看:0 回复:1 评论:0 创建时间:2020-08-10T21:13:17
【作品展示】

【作品介绍】
用了For循环可以不断的玩石头剪刀布,也可以想停就停,想猜就猜,试试你的运气
【作品源代码】
import random
for n in range(100):
player = input('你想出的是剪刀(j),石头(s),布(b),停止(z)')
playerPc = random.randint(1, 3)
if (playerPc == 1):
playerPc = 'j'
msg = '剪刀(j)'
if (playerPc == 2):
playerPc = 's'
msg = '石头(s)'
if (playerPc == 3):
playerPc = 'b'
msg = '布(b)'
print(('电脑出的是:' + msg))
if (playerPc == 'j' and player == 's'):
print('玩家胜利!')
if (playerPc == 'j' and player == 'b'):
print('电脑胜利!')
if (playerPc == 's' and player == 'j'):
print('电脑胜利!')
if (playerPc == 's' and player == 'b'):
print('玩家胜利!')
if (playerPc == 'b' and player == 's'):
print('电脑胜利!')
if (playerPc == 'b' and player == 'j'):
print('玩家胜利!')
if (playerPc == player):
print('平局哦!再来一次')
if (player == 'z'):
break
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn