|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 hveagle 于 2022-9-20 19:47 编辑
题目700000002
20220918
上题目最佳答案
答案主人
ba21
答案内容
- import random
- rpsLst = ['石头', '剪刀', '布']
- while True:
- rps = input('Rock Paper Scissor:')
- cRpsIdx = random.randint(0, len(rpsLst)-1)
- print('电脑出:', rpsLst[cRpsIdx])
- rpsIdx = rpsLst.index(rps)
- rpsLen = len(rpsLst)
- if (rpsIdx-1)%rpsLen == cRpsIdx:
- print('你输了')
- elif (rpsIdx+1)%rpsLen == cRpsIdx:
- print('你赢了')
- else:
- print('平局')
复制代码
本周进度
一 二 三 四 五 六 七
题目导入
<----- 箭头指向的是胜利一方
石头 <----- 剪刀
剪刀 <----- 布
布 <----- 石头
题目要求
结果:
- Rock Paper Scissor:剪刀
- 布, 你胜了
- 还要玩吗(Y/N):Y
- Rock Paper Scissor:剪刀
- 剪刀, 平局
复制代码
题目最佳答案
下一题揭晓
 欢迎大家答题!
- import random
- rpsLst = ['石头', '剪刀', '布']
- ask = 'Y'
- while ask.upper() != 'N':
- rps = input('Rock Paper Scissor:')
- cRpsIdx = random.randint(0, len(rpsLst)-1)
- cRps = rpsLst[cRpsIdx]
- rpsIdx = rpsLst.index(rps)
- rpsLen = len(rpsLst)
- if (rpsIdx-1)%rpsLen == cRpsIdx:
- print('%s,你输了' % cRps)
- elif (rpsIdx+1)%rpsLen == cRpsIdx:
- print('%s,你赢了' % cRps)
- else:
- print('%s平局' % cRps)
- ask = input('还要玩吗(Y/N):')
复制代码
|
|