日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Python实现石头-剪刀-布小游戏

發布時間:2023/12/2 python 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python实现石头-剪刀-布小游戏 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

近日在學習Python的一些基礎知識,覺得還是很有趣的一個一門語言!就目前的學習的一些知識,編寫了一些一個簡單的石頭剪刀布的游戲。主要是熟悉一些Python的一些控制語句。

import random while 1:s=int(random.randint(1,3))print(s)print()if s==1:ind="stone"elif s==2:ind="scissors"elif s==3:ind="paper"m=input('Please input your option,if you input the end, this game will be end. ')blist=['stone','scissors','paper']if (m not in blist) and (m!='end'):print('your input is wrong and please input the right option again or end the game: ')elif (m not in blist) and (m=='end'):print('the game is ending now...')breakelif m==ind:print('draw')elif (m=='stone' and ind=='scissors') or (m=='paper' and ind=='stone') or (m=='scissors' and ind=='paper'):print('you win this game')elif (m=='stone' and ind=='paper') or (m=='paper' and ind=='scissors') or (m=='scissors' and ind=='stone'):print( 'you loss this game')

下面是結果:

看著應該還可以,比較簡單,我會繼續學些!

總結

以上是生活随笔為你收集整理的Python实现石头-剪刀-布小游戏的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。