<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 2.8 練習 1\. 什么是數據?什么是數據類型? 2\. Python 中的數值類型有哪些?對數值類型能執行什么運算? 3\. Python 中的字符串有哪些表示方式?對字符串類型能執行什么運算? 4\. Python 中的布爾類型提供了哪兩個值?對布爾類型數據能執行什么運算? 5\. Python 中的列表類型和其他編程語言中常見的數組類型有何異同? 6\. Python 中的字符串類型和列表類型有何異同? 7\. Python 中的元組類型與列表類型有何異同? 8\. 說 Python 中的變量是動態類型的,這是什么意思? 9\. 哪些運算符針對不同類型的數據有不同意義? 10\. 利用 Python 計算以下表達式。如果出錯,找出原因。 (1)`4.0 / 10.0 + 3.5 * 2` (2)`10 % 4 + 6 /2` (3)`abs(4 ? 20 / 3) ** 3` (4)`sqrt(4.5 ? 5.0) + 7 * 3` (5)`3 * 10 / 3 + 10 % 3` (6)`3L ** 3` 11\. 將下列數學式用 Python 表達式表示出來。假設已通過 import math 導入了數學庫。 (1)`(a + b) ′ c` (2)`n(n - 1) / 2` (3)![](https://box.kancloud.cn/2016-02-22_56cafcdd0eaaf.png) (4)![](https://box.kancloud.cn/2016-02-22_56cafcdd1ced4.png) (5)`(y2 - y1)/(x2 - x1)` 12\. 設計程序:輸入球體半徑 r,計算球體的體積(![](https://box.kancloud.cn/2016-02-22_56cafcdd2c653.png))和表面積(![](https://box.kancloud.cn/2016-02-22_56cafcdd394b8.png))。 13\. 設計程序:輸入平面上兩個點的坐標(x1,y1)和(x2,y2),計算兩點間距離。距離公式為 d =![](https://box.kancloud.cn/2016-02-22_56cafcdd47aa4.png) 。 14\. 設計程序:輸入以英尺英寸為單位的身高數據,轉換成以米為單位的數據。(1 英尺=12 英寸=0.305 米) 15\. 設計程序:輸入 5 個考試分數,計算平均分。 16\. 假設已經執行了如下語句: ``` >>> import string >>> s1 = "programming" >>> s2 = "language" ``` (1)求下列各表達式的值。 a)`s1[1]` b)`s1[:4]` c)`s1[0] + s2[:3]` d)`s2[5:len(s2)]` e)`"Python " + s2` f)`2 * (s1[:2] + s2[-1])` g)`string.count(s1,'r') + string.find(s1,'r')` h)`string.ljust(string.upper(s2),10)` (2)利用 s1、s2 和字符串操作,寫出能產生下列結果的表達式。 a)`'gram'` b)`'ProgLang'` c)`'la la la'` d)`' language '` e)`'progrAmming lAnguAge'` 17\. 求下列字符串格式化操作的結果。如果出錯,解釋原因。 (1)`"%s has won %d gold medals." % ("China",38)` (2)`"Hello %s." % ("Tom","Tim")` (3)`"%0.2f %0.2f" % (3.1416,2.718)` (4)`"Time left %02d:%05.2f" % (1,5.432)` (5)`"%3d" % ("14")` 18\. 將下列條件用布爾表達式表示出來: (1)a 大于 b,或者 a 小于等于 b 且 c 不等于 0。 (2)a 和 b 的差不超過 0.005。 (3)字符串 s 以“水”開頭,并且包含子串“酒旗”。 (4)字符串 s1 的長度為 10,或者 s1 在字符串 s2 中出現 2 次。 19\. 若 P 表示“x 小于等于 y 并且 x 大于 0”,那么 not P 表示什么? 20\. 假設已經執行了如下語句: ``` >>> s1 = [1,2,3,4] >>> s2 = ['a','b','c'] ``` 求下列各表達式的值。 (1)`s1 + s2` (2)`2 * s1 + 3 * s2` (3)`s1[:3]` (4)`s2[0:len(s2)]` 21\. 將第 20 題中的 s1 和 s2 改為元組,重做(1)~(4)。 22\. 設計程序:輸入五分制的分數(0~5),輸出相應的等級制分數:5=A,4=B,3=C,2=D,1=F,0=F。(提示:仿照程序 2.5 的查找方法) 23\. 設計程序:輸入百分制的分數(0~100),輸出相應的等級制分數:90~100=A,80~89=B,70~79=C,60~69=D,0~59=F。
                  <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>

                              哎呀哎呀视频在线观看