Python 实现简单的石头剪刀布小游戏
生活随笔
收集整理的這篇文章主要介紹了
Python 实现简单的石头剪刀布小游戏
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
直接上代碼:
import randomperson = int(input('請輸入石頭[0],剪刀[1],布[2]:')) computer = random.randint(0,2)print('機器人輸入的是:%d'%(computer))if person == 0 and computer == 1:print('你贏了') elif person == 1 and computer == 2:print('你贏了') elif person == 2 and computer == 0:print('你贏了') elif person == computer:print('平手') else:print('你輸了') 《新程序員》:云原生和全面數(shù)字化實踐50位技術專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的Python 实现简单的石头剪刀布小游戏的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python 输入与输出
- 下一篇: Python 实现9*9乘法表