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

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Python 程序:將十進制轉換為二進制,八進制和十六進制 > 原文: [https://www.programiz.com/python-programming/examples/conversion-binary-octal-hexadecimal](https://www.programiz.com/python-programming/examples/conversion-binary-octal-hexadecimal) #### 在此程序中,您將學習將十進制轉換為二進制,八進制和十六進制,并顯示它。 要理解此示例,您應該了解以下 [Python 編程](/python-programming "Python tutorial")主題: * [Python 編程內置函數](/python-programming/built-in-function) * * * 十進制是最廣泛使用的數字系統。 但是,計算機只能理解二進制文件。 二進制,八進制和十六進制數系統密切相關,我們可能需要將十進制轉換為這些系統。 十進制以 10 為底(十個符號 0-9 用于表示數字),類似地,二進制以 2 為底,八進制以 8 為底,十六進制為 16。 前綴為`0b`的數字被認為是二進制,`0o`被認為是八進制,`0x`被認為是十六進制。 例如: ```py 60 = 0b11100 = 0o74 = 0x3c ``` ## 源代碼 ```py # Python program to convert decimal into other number systems dec = 344 print("The decimal value of", dec, "is:") print(bin(dec), "in binary.") print(oct(dec), "in octal.") print(hex(dec), "in hexadecimal.") ``` **輸出** ```py The decimal value of 344 is: 0b101011000 in binary. 0o530 in octal. 0x158 in hexadecimal. ``` **注意**:要測試程序的其他十進制數字,請在程序中更改`dec`的值。 在該程序中,我們使用了內置函數`bin()`,`oct()`和`hex()`將給定的十進制數字轉換為相應的數字系統。 這些函數采用整數(十進制)并返回字符串。
                  <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>

                              哎呀哎呀视频在线观看