<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之旅 廣告
                # 習題 29: 如果(if) 下面是你要寫的作業,這段向你介紹了“if語句”。把這段輸入進去,讓它能正確執行。然后我們看看你是否有所收獲。 <table class="highlighttable"><tbody><tr><td class="linenos"> <div class="linenodiv"> <pre> 1&#13; 2&#13; 3&#13; 4&#13; 5&#13; 6&#13; 7&#13; 8&#13; 9&#13; 10&#13; 11&#13; 12&#13; 13&#13; 14&#13; 15&#13; 16&#13; 17&#13; 18&#13; 19&#13; 20&#13; 21&#13; 22&#13; 23&#13; 24&#13; 25&#13; 26&#13; 27&#13; 28&#13; 29</pre> </div> </td> <td class="code"> <div class="highlight"> <pre>people = 20&#13; cats = 30&#13; dogs = 15&#13; &#13; &#13; if people &lt; cats:&#13; print "Too many cats! The world is doomed!"&#13; &#13; if people &gt; cats:&#13; print "Not many cats! The world is saved!"&#13; &#13; if people &lt; dogs:&#13; print "The world is drooled on!"&#13; &#13; if people &gt; dogs:&#13; print "The world is dry!"&#13; &#13; &#13; dogs += 5&#13; &#13; if people &gt;= dogs:&#13; print "People are greater than or equal to dogs."&#13; &#13; if people &lt;= dogs:&#13; print "People are less than or equal to dogs."&#13; &#13; &#13; if people == dogs:&#13; print "People are dogs."&#13; </pre> </div> </td> </tr></tbody></table> ### 你應該看到的結果 ~~~ $ python ex29.py Too many cats! The world is doomed! The world is dry! People are greater than or equal to dogs. People are less than or equal to dogs. People are dogs. $ ~~~ ### 加分習題 猜猜“if語句”是什么,它有什么用處。在做下一道習題前,試著用自己的話回答下面的問題: 1. 你認為 if 對于它下一行的代碼做了什么? 1. 為什么 if 語句的下一行需要 4 個空格的縮進? 1. 如果不縮進,會發生什么事情? 1. 把習題 27 中的其它布爾表達式放到``if語句``中會不會也可以運行呢?試一下。 1. 如果把變量 people, cats, 和 dogs 的初始值改掉,會發生什么事情?
                  <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>

                              哎呀哎呀视频在线观看