<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 應用:猜拳游戲 **?標** 1. 強化 多個條件 的 邏輯運算 2. 體會 import 導?模塊(“?具包”)的使? ## 1.**需求** 1. 從控制臺輸?要出的拳 —— ?頭(1)/剪?(2)/布(3) 2. 電腦 隨機 出拳 —— 先假定電腦只會出?頭,完成整體代碼功能 3. ?較勝負 ## 運行效果: ![](https://img.kancloud.cn/2a/ea/2aea39a31ad54ed90daf3a55c50e3064_933x510.png) 2\. 參考代碼: ~~~ import random player = input('請輸入:剪刀(0) 石頭(1) 布(2):') player = int(player) # 產生隨機整數:0、1、2 中的某一個 computer = random.randint(0,2) # 用來進行測試 #print('player=%d,computer=%d',(player,computer)) if ((player == 0) and (computer == 2)) or ((player ==1) and (computer == 0)) or ((player == 2) and (computer == 1)): print('獲勝,哈哈,你太厲害了') elif player == computer: print('平局,要不再來一局') else: print('輸了,不要走,洗洗手接著來,決戰到天亮') ~~~ ## 隨機數的處理 * 在 Python 中,要使?隨機數,?先需要導? 隨機數 的 模塊 —— “?具包” ~~~ import random ~~~ * 導?模塊后,可以直接在 模塊名稱 后?敲?個 . 然后按 Tab 鍵,會提示該模塊中包含的所有函數 * random.randint(a, b) ,返回 \[a, b\] 之間的整數,包含 a 和 b
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看