pmt = [0,0,0,0] #周偉玲程式設計586設定串列list
pmt[0]=float(input('躉繳金額: '))#float函數轉化為實數(浮點數)
for nper in range(1,4):
pmt[nper] = float(input('第'+str(nper)+'期回收: '))
def npv(rate):
y = - pmt[0]
for j in range(1,4):
y = y + pmt[j]/(1+rate)**j
return y
a, b, gap, f = 0.0, 1.0, 9.0, 9.0
maxerror = 0.000001
loopNumber = 1
while (gap > maxerror and abs(f) > maxerror and loopNumber < 100):
loopNumber+=1
c = (a+b)/2;
f = npv(c);
if ( abs(f) > maxerror and gap > maxerror):
if ( f>0 ):
a = c
else:
b = c
gap = b-a;
print('周偉玲報酬率: ', c)
print('周偉玲淨現值: ', f)
print('周偉玲迴圈次數: ', loopNumber)
Javascript在網頁就可以執行不需要開啟Spyder sin執行 cos執行 橫軸 以上程式碼 <style>BUTTON{BORDER:GREEN 5PX SOLID;BORDER-RADIUS:30PX;}</style> <h1>Javascript在網頁就可以執行不需要開啟Spyder</h1> <button onclick="LHsin()">sin執行</button> <button onclick="LHcos()">cos執行</button> <button onclick="xLine()">橫軸</button> <canvas height="400" id="my" style="background: black;" width="1200"></canvas> <script> var c = document.getElementById("my"); var cty = c.getContext("2d"); var g = 0.01;//增加一個廣域變數,用在下面的Math.sin(g*x); var h = 195; function LHsin() { var x = 0; var y = 200; cty.beginPath(); cty.lineWidth = 5; cty.moveTo(x,y); while (x < 1000){ x = x + 1; y = 200 - h * Math.sin(g*x); cty.lineTo(x, y); cty.strokeStyle = "yellow"; cty.stroke(); }; } function LHcos() { var x = 0; var y = 200-h;//上面的sin是y =200這裡要改掉 cty.beginPath(); cty.l...
https://d11117315111.blogspot.com/2025/06/pythonexcel-pv_23.html
回覆刪除https://d11117315111.blogspot.com/2025/06/javascriptpythonirr.html
https://d11117315111.blogspot.com/2025/06/pythonjavascriptexcel-irr.html