發表文章

杜品葳Python_Javascript網路執行_EXCEL_IRR二分法

圖片
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.00000001 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語言

杜品葳二分法求內部報酬率

圖片
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網頁BUTTON按鈕ONCLICK事件call呼叫函數

物件導向設計OOP=Object-Oriented Programming 主詞subject受詞object東方的oriental id=identity,身分證id card, division區塊,段落 杜品葳執行 函數名稱()將要執行的程式碼用curly braces圍住。 PYTHON換列就是;區隔指令。PYTHON同一個縮排,就是{}的同一區塊。 期中考心得 不編排PYTHON程式碼,期中考後再練習。 JAVASCRIPT的字典 dict =new Map([["2303","聯電"],["2330","台積電"],["2880","華南金"],['AAPL','蘋果公司'],['C','花旗銀行'],['T','美國電話電報']]);//宣告配對(字典) PYTHON的字典 dict ={"2303":"聯電","2330":"台積電","2880":"華南金",'AAPL':'蘋果公司','C':'花旗銀行','T','美國電話電報'}

杜品葳Javascript物件導向Python物件導向

物件導向設計OOP=Object-Oriented Programming 主詞subject受詞object東方的oriental id=identity,身分證id card, division區塊,段落 .方法get()是取得對應的值,功能同字典 dict.get(s1.code)從dict字典取得索引為s1.code的值 物件導向設計OOP=Object-Oriented Programming 主詞subject受詞object東方的oriental id=identity,身分證id card, division區塊,段落

杜品葳整合開發環境IDE的Jupyter編輯Python程式碼

SPYDER執行PYTHON程式碼截圖 PYTHON程式碼 from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 banks=['摩根大通','美國銀行','中國工商','富國銀行','匯豐銀行','巴黎銀行'] def ABC(): #畫圖 define自訂函數 global b1 #宣告b1是廣域GLOBAL變數,其他函數也可使用 txt = '' for i in range(len(banks)): txt += banks[i] + ' ' b1=Label(canvas,text=txt,font='Arial 20 bold') b1.pack(side=TOP) def XYZ(): #清除視窗的all所有canvas圖 banks.append('三菱銀行') banks.append('台灣銀行') ABC()#結束XYZ之前給它顯示 def kill(): b1.pack_forget() tk = Tk() tk.title("賴青德python建立tkinter視窗使用者介面") #也可以定義視窗名為 window, root課本都如此習慣 canvas = Canvas(tk, width=400, height=400) canvas.pack() btn1 = Button(tk, text="賴青德銀行", command = ABC, bg='black',fg='white').pack(side=LEFT) btn2 = Button(tk, text="賴青德增加", command = XYZ).pack(side=LEFT) btn3 = Button(tk, text="賴青德刪除", command = kill).pack(side=LEFT) tk.mainloo...

甲杜品葳python串列List(陣列Array),元組Tuple,集合Set,字典Dict

全球市場價值最大的銀行 按鈕BUTTON push pop刪除最後一項 CSS也可以in-line
利用w3schools練習的pythomn指令 animal = ["豬", "牛", "羊", '貓'] #python語言的註解comments x = animal.copy() print(animal) x.reverse() #將x反轉reverse print(x) animal.append('狗') print(animal) y = animal.copy() y.reverse() #將x反轉reverse print(y) UL=UNDERER LIST, OL=ORDERED LIST, LI=LIST 大括號{ }CURLY BRACKET, CURLY捲 中括號[ ]SQUARE BRACKET, SQUARE方形 小括號( )CIRCLE BRACKER, CIRCLE圓 圓周CIRCUMFERENCE 直徑DIAMETER 半徑RADIUS BORDER邊界, SOLID實心, PX=PIXEL點,