發表文章

目前顯示的是 6月, 2025的文章

郭俞汝Python_Javascript網路執行_EXCEL_IRR二分法

圖片
郭俞汝解說影片 郭俞汝6/25截圖 以上所有程式碼 pmt = [0,0,0,0] #郭俞汝程式設計586設定串列list pmt[0]=float(input('郭俞汝躉繳金額: '))#float轉換成實數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也學會人工智慧使用最多的PYTHON語言 嵌入網頁的指令<IFRAME SRC="網址"> </IFRAME>

郭俞汝二分法求內部報酬率

圖片
head/head, body/body畫蛇添足,可拿掉,因為部落格架構已經下這些命令 躉繳 第1期 第2期 第3期 注意,包含首期躉繳的現金流量都大於0。 輸出: 報酬率: 淨現值: 迴圈次數: 郭俞汝學習程式設計程式碼如下 <IFRAME WIDTH='100%'SRC='https://zh.wikipedia.org/zh-tw/%E4%BA%8C%E5%88%86%E6%B3%95_(%E6%95%B8%E5%AD%B8)'></IFRAME> head/head, body/body畫蛇添足,可拿掉,因為部落格架構已經下這些命令 <style> h1 {margin: 0;padding:20px 0;color:black;  text-shadow: 4px 4px 2px pink;} .Takming {border: 20px outset red;background-color: green;   color: white; text-align: center;} .pmt {width: 60pt;height: 20pt;background-color: coral;   color: white; text-align: right;} </style> <table border="1"> <tr align="center"><td>躉繳</td><td>第1期</td><td>第2期</td><td>第3期</td></tr> <tr><td><input class="pmt" type="number" /></td>    <td><input class="pmt" type="number" /></td>    <td><input...

郭俞汝JAVASCRIPT計算現值PresentValue和Python比較

圖片
利率y(rate) 期數n(nper) 金流m(pmt) 終值f(fv) 參考郭俞汝金融市場講義https://drive.google.com/file/d/17z6UZgN5fC2XCO1L8_BQs57dgQXzbwou/view?usp=sharing 郭俞汝學習HTML+CSS+JavaScript程式碼 body指令拿掉因為沒有作用,部落格已經設定body 在Spyder開發環境編寫與執行Python 第一個python沒有用函數def """# PYTHON 註解三個單引號或雙引號前後""" r=float(input('利率: '))#input輸入是字串 n=float(input('期數: '))#要計算轉成實數 m=float(input('收付: '))#浮點float f=float(input('終值: ')) pv = f/(1+r)**n pv +=m/r*(1-1/(1+r)**n) print('計算現值',pv) """# PYTHON 註解三個單引號或雙引號前後""" def pv(r,n,m,f):#自訂函數 p =m/r*(1-1/(1+r)**n)+f/(1+r)**n return p#執行函數的結果傳回去 #r=float(input('利率: '))#input輸入是字串 n=float(input('期數: '))#要計算轉成實數 m=float(input('收付: '))#浮點float f=float(input('終值: ')) for i in range(1,10):#迴圈 r=i*0.01 x=pv(r,n,m,f) print('利率',r,'價格',x) 影片

Python tkinter繪圖對比EXCEL

圖片
def pv(r,n,m,f):#郭俞汝函數參數r,n,m,f p = m/r*(1 - 1/(1+r)**n)+f/(1+r)**n return p#執行函數的結果傳回去 n=float(input('期數: '))#要計算轉為實數real nubers m=float(input('收付: '))#浮點點float f=float(input('終值: ')) for i in range(1,10):#迴圈 r = i*0.01 x=pv(r,n,m,f) print('利率 ', r ,'價格 ', x) import tkinter as tk#輸入tkinter繪圖 root = tk.Tk() root.title('郭俞汝python tkinter') root.geometry('600x300')#寬度width改成600 canvas = tk.Canvas(root, width=600, height=600) # 加入 Canvas 畫布 canvas.pack() x, y = 0, 0 canvas.create_line(0, 400, 500, 400, width=5,fill='pink') for x in range(1,400): x1 = x+1 y1 = 400 - pv(x1,n,m,f)*400 canvas.create_line(x, y, x1, y1, width=5,fill='blue') canvas.pack() x = x1 y = y1 root.mainloop()