久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      如何用python計算圓周率?

      如何用python計算圓周率?

      如何用python計算圓周率?

      python計算圓周率的方法:

      圓周率沒有精確的計算公式,所以只能用近似的方式計算它的近似值。

      我們運用蒙特卡羅方法,思路很簡單,在下面圖形中隨機拋置大量的點, 計算落在1/4圓內(nèi)的點的數(shù)量。

      如何用python計算圓周率?

      為了得到pi值,由思路,我們知道需要引用random、math以及time數(shù)據(jù)庫,具體代碼如下:

      # pi.py from random import random from math import sqrt from time import clock DARTS = 1200 hits = 0 clock() if dist <= 1.0: hits = hits + 1 pi = 4 * (hits/DARTS) print("Pi的值是 %s" % pi) print("程序運行時間是 %-5.5ss" % clock())

      推薦教程:《python》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號