猜拳游戏
import random print('*'*20) print("***欢迎来到猜拳游戏***\n" "提示(请输入数字)\n" "1(石头),2(剪刀),3(布),0(退出游戏)\n" "赢一局得3分,输一局扣3分,平局不得分\n") y = 0 p = 0 s = 0 f = 0 while True: play = input("请出拳:") computer = random.randint(1, 3) res = play.isdigit() if res == True: player = int(play) if player <= 3 and player >=0: if (computer==1 and player==2) or (computer==2 and player==3) or (computer==3 and player==1): print("你输了,请再接再厉") s += 1 elif computer == player: print("平局") p += 1 elif player == 0: break else: print("你赢了!请继续加油") y += 1 else: print("输入错误,请重新输入!" "提示:" "1(石头),2(剪刀),3(布),0(退出游戏)") else: print("输入错误,请输入数字") f = y*3 - s*3 print("你赢了%d局,输了%d局,平局%d,共计得分%s"%(y,s,p,f))
作者:无荨
-------------------------------------------
个性签名:学IT,就要做到‘活到老学到老’!
如果觉得这篇文章对你有小小的帮助的话,别忘记点个“推荐”哦!