<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # Python 程序:使用遞歸將十進制轉換為二進制 > 原文: [https://www.programiz.com/python-programming/examples/decimal-binary-recursion](https://www.programiz.com/python-programming/examples/decimal-binary-recursion) #### 在此程序中,您將學習使用遞歸函數將十進制數轉換為二進制數。 要理解此示例,您應該了解以下 [Python 編程](/python-programming "Python tutorial")主題: * [Python `if...else`語句](/python-programming/if-elif-else) * [Python 函數](/python-programming/function) * [Python 遞歸](/python-programming/recursion) * * * 通過將數字連續除以 2 并以相反順序打印其余部分,將十進制數轉換為二進制。 ![How to convert decimal to binary?](https://img.kancloud.cn/1a/41/1a41a62ef85649507929728715aad511_740x400.png "Convert Binary to Decimal") * * * ## 源代碼 ```py # Function to print binary number using recursion def convertToBinary(n): if n > 1: convertToBinary(n//2) print(n % 2,end = '') # decimal number dec = 34 convertToBinary(dec) print() ``` **輸出** ```py 100010 ``` 您可以在上述程序中更改變量`dec`,然后運行它以測試其他值。 * * * 該程序僅適用于整數。 它不適用于具有分數值的實數,例如:`25.5`,`45.64`等。 我們鼓勵您創建 Python 程序,自行將所有實數的十進制數轉換為二進制。
                  <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>

                              哎呀哎呀视频在线观看