<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之旅 廣告
                [TOC] >[success] # 流程控制和循環語句 ~~~ 1.流程控制語句if 2.循環語句while/for 3.循環語句while ... else .. /沒有break 終止循環完后執行else后內容,有則不執行 ~~~ >[success] # 控制語句if ~~~ 1.格式: if 判斷條件(布爾類型): 執行的內容 ~~~ >[danger] ##### 案例 * 一個分支的判斷 ~~~ if 6 < 10: print("六小于十") 打印結果: 六小于十 ~~~ * 兩種分支對或錯 ~~~ 1.判斷6是否大于10,真執行if ,假就執行else ~~~ ~~~ if 6 > 10: print("六小于十") else: print("回答錯誤") 打印結果: 回答錯誤 ~~~ * 多條件分支 ~~~ 1.利用elif 進行多個條件的分割,進行條件的判斷 ~~~ ~~~ score = int(input("請輸入分數")) if score > 100: print("我擦,最高分才100...") elif score >= 90: print("A") elif score >= 80: print("B") elif score >= 60: print("C") else: print("不及格") 請輸入分數50 打印結果: 不及格 ~~~ >[success] # while 循環語句 ~~~ 1.while 條件:循環體 2.break 終止本次循環 3.continue 見底停止本次循環 4.pass 暫時略過 ~~~ >[danger] ##### while...else... ~~~ 1.循環語句while ... else .. /沒有break 終止循環完后執行else后內容,有則不執行 ~~~ ~~~ count = 0 while count <= 5: count += 1 if count == 3: break print("Loop", count) else: # 上面代碼中有break 所以不會執行else 中內容 print("循環正常執行完啦") print("-----跳出循環------") 打印結果: Loop 1 Loop 2 -----跳出循環------ ~~~ >[danger] ##### 案例 計算一百以內的和 ~~~ count = 0 sum = 0 while count<100: count += 1 sum += count print(sum) 打印結果: 5050 ~~~ >[success] # 循環語句for ~~~ for i in 循環東西: 代碼內容 ~~~ >[danger] ##### 案例 ~~~ s = "你是我的" for i in s: print(i) 打印結果: 你 是 我 的 ~~~ >[danger] ##### 產生迭代數字 -- range ~~~ 1. 兩個參數的時候必須從小到大 2. 一個參數的時候默認其實從0到指定參數 3. 顧頭不顧腚產生的數字 ~~~ ~~~ for i in range(3,10): print(i) for i in range(10): print(i) for i in range(0,10,3): print(i) for i in range(10,0,-2): print(i) for i in range(10,-1,-2): print(i) ~~~
                  <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>

                              哎呀哎呀视频在线观看