用户:
张赵桓1号查看:0 回复:3 评论:0 创建时间:2022-05-09T12:45:22
【作品展示】

【作品介绍】
哪出问题了?代码哪出问题了?只用代码,不用积木
【作品源代码】
import random
import random as r # 引进模块
a = r.random() # 参数二
wo = input("请出拳('石头剪刀布')") # 开始出拳
参数 = random.randint(0, 2) # 参数对照
print(参数)
机器 = ('石头', '剪刀', '布') # 列表石头剪刀
if (参数 == 0) and (a == 0): # 随机出拳
print("石头")
elif (参数 == 1) and (a == 0):
print('剪刀')
else:
if (a == 0):
print('布')
if (wo == '石头') or (wo == '剪刀') or (wo == '布'):
a = 0
if (wo == '石头') and (机器 == '剪刀'):
print('剪刀')
print('victory!')
elif (wo == '石头') and (机器 == '布'):
print('布')
print('fail!')
elif (wo == '剪刀') and (机器 == '石头'):
print('石头')
print('fail!')
elif (wo == '剪刀') and (机器 == '布'):
print('布')
print('victory!')
elif (wo == '布') and (机器 == '剪刀'):
print('剪刀')
print('fail!')
elif (wo == '布') and (机器 == '石头'):
print('石头')
print('victory!')
else:
print(wo)
print('tie!')
print(wo)
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn