|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
【求助帖】请及时确认最佳答案,下次提问时可以得到更多关注,问题可以更快解决
import random
lhy = int(input("大佬,请出个拳:"))
com = random.randint(0,2)
print("com=",com)
times = 3
while lhy:
import random
lhy = int(input("大佬,请出个拳:"))
com = random.randint(0, 2)
print("com=", com)
times = times - 1
#剪刀(0) 布(1) 石头(2)
if times==0:
print("机会用完了")
print("游戏结束")
break
else:
if (lhy==0 and com==1) or (lhy==1 and com==2) or(lhy==2 and com==0):
print('lhy胜')
else:
if lhy == com:
print("平局")
else:
print("com胜")
continue
本帖最后由 jackz007 于 2019-10-30 15:50 编辑
- #-*- coding:gbk -*-
- import random
- times = 3
- win , lose , draw = 0 , 0 , 0
- while times:
- com = random . randint(0 , 2)
- lhy = int(input("大佬,请出个拳:"))
- if lhy >= 0 and lhy <= 2:
- if (lhy == 0 and com == 1) or (lhy == 1 and com == 2) or (lhy == 2 and com == 0):
- win += 1
- print('lhy 胜')
- elif(lhy == com):
- draw += 1
- print('平局')
- else:
- lose += 1
- print('lhy 负')
- times -= 1
- print()
- print('总结果是 lhy %d 胜,%d 负,%d 平' % (win , lose , draw))
复制代码
|
|