發表文章

郭俞汝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()

Javascript數學函數sin與cos對比EXCEL函數

圖片
Javascript在網頁就可以執行不需要開啟Spyder sin執行 cos執行 橫軸 以上原始程式碼 <style>BUTTON{BORDER:PINK 7PX SOLID;BORDER-RADIUS:30PX;FONT-SIZE:30PX;COLOR:PURPLE}</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);//數學math正弦函數   cty.lineTo(x, y);   cty.strokeStyle = "yellow";   cty.stroke();    }; } function LHcos() { var x = 0; var y = 200-h;//...

三個Javascript函數sin,cos與canvas.font

圖片
郭俞汝解說程式碼 sin執行 cos執行 橫軸

郭俞汝Javascript執行三角函數繪圖

圖片
Javascript在網頁就可以執行不需要開啟Spyder 郭俞汝執行

郭俞汝python繪製三角函數與powerpoint製作影片

圖片
python程式碼 from tkinter import * #或者import tkinter as tk import math tk = Tk() #建構視窗名為tk tk.geometry('1200x400')#視窗 寬1200像素 tk.title("郭俞汝python tkinter三角函數") canvas = Canvas(tk, width=1200, height=400, bg='black') canvas.grid(row=0,column=0,padx=5,pady=5,columnspan=3) delay=2# milliseconds, 1/1000秒 x1,y1,z1=0,200,10#python特徵,多變數=對等值 h=190 #上下範圍,相當於數學的1到-1 L1=canvas.create_line(0,200,1200,200,fill='white',width=5) def YUUUU(): global x1, y1, z1#gLobel全球,Local當地 x2 = x1 + 1 #換到下一個+1 y2=200 - h*math.sin(0.02*x2) z2=200 - h*math.cos(0.02*x2) L1=canvas.create_line(x1,y1,x2,y2,fill='pink',width=10) L2=canvas.create_line(x1,z1,x2,z2,fill='white',width=10) if (x2

Word File Processing in Python(Python處理Word檔案)

圖片
embed遷入(bed床,放入床上,嵌入鑽戒) 影片重點 Let's develo; brains. 作文,在捷運上讓座let給老弱婦孺 yield(投降,收益) YTM=Yield to Maturity=到期收益率 nominal yield=coupon rate=票面利率 利用python編輯edit建立create word 檔案 Process 處理....procedure程序 SOP python命令,給文件新增加一個段落 document.add_paragraph('文字內容',格式) 網頁javascript命令 document.create_element('P'); 維基百科python了解 Python was conceived in the late 1980s [ 42 ]  by Guido van Rossum at  Centrum Wiskunde & Informatica  (CWI) in the  Netherlands ; it was conceived as a successor to the  ABC  programming language, which was inspired by  SETL , [ 43 ]  capable of  exception handling  and interfacing with the  Amoeba  operating system. [ 12 ]  Python implementation began in December 1989. [ 44 ]  Van Rossum assumed sole responsibility for the project, as the lead developer, until 12 July 2018, when he announced his "permanent vacation" from responsibilities as Python's " benevolent dictator for life " (BDFL); this ...

郭俞汝Javascript網頁BUTTON按鈕ONCLICK事件call呼叫函數

物件導向設計OOP=Object-Oriented Programming 主詞subject受詞object東方的oriental id=identity,身分證id card, division區塊,段落 郭俞汝執行 函數名稱()將要用的程式碼用curly braces圍住。  JAVASCRIPT的字典 dict =new Map([["2303","聯電"],["2330","台積電"],["2880","華南金"],['AAPL','蘋果公司'],['C','花旗銀行'],['T','美國電話電報']]);//宣告配對(字典)   PYTHON的字典 dict ={"2303":"聯電","2330":"台積電","2880":"華南金",'AAPL':'蘋果公司','C':'花旗銀行','T','美國電話電報'}

郭俞汝Javascript物件導向方法是物件的函數

物件導向設計OOP=Object-Oriented Programming 主詞subject受詞object東方的oriental id=identity,身分證id card, division區塊,段落 .方法get()是取得對應的值,功能同字典 dict.get(s1.code)從dict字典取得索引為s1.code的值 郭俞汝以上的程式碼 <h1>物件導向設計OOP=Object-Oriented Programming</h1> 主詞object東方的oriental <p id="cat"></p> <p id="dog"></p> <p>id=identity,身分證id card, division區塊,段落</p> <script> dict =new Map([["2303","聯電"],["2330","台積電"],["2880","華南金"]]);//宣告配對(字典) class Stock{      //宣告類別   constructor(code, shares, price){//建構子constructor     this.code = code;     this.shares = shares;     this.price = price;} } s1 = new Stock("2330", 100, 1000); //建構子Stock建構s1 s2 = new Stock("2880", 1000, 30); //建構子Stock建構s2 st = s1.code+' 股數 '+s1.shares.toString()+'<BR>'+s2.code.toString()+' 股數 '+s2.shares; document.getElementById('cat').innerHTML = st;   st =dict.get(...

郭俞汝Javascript使用瀏覽器Browser就可以編譯出Interpreting

圖片
python命令command='執行的程式' Javascript ONCLICK='執行的程式()'ONCLICK按下滑鼠的事件on click按下 郭俞汝增加 郭俞汝銀行 刪除串列的最後一個元素 心得與期中考重點 &LT;DIV STYLE="WIDTH: 200PX; HEIGHT 60PX; BACKGROUND: PINK;"&GT;&LT;/DIV&GT; 沒必要如此做程式就可以執行,方便在未來maintain後來的python庫格與跳行都是命。跳行行就是取代;號,用相同的空格數(縮排一起)就{}

郭俞汝python,tkinter,Entry建構輸入工具,pop移除串列元素

圖片
#郭俞汝 python註解comment使用# '''前後用三個引號可以單引,也可以雙引 ''' 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(bank.get()) ABC()#結束XYZ之前給它顯示 def kill(): banks.pop()#移除串列banks元素 ABC()#執行自訂函數(寫在前面 tk = Tk()#建構TK global bank#宣告廣域變數bank bank = StringVar(tk)#bank視窗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, fg='blue').pack(side=LEFT) btn3 = Button(tk, text="刪除", command = k...

郭俞汝整合開發環境IDE的Jupyter編輯Python程式碼

圖片
Tkinter是Tk GUI工具包的Python繫結包。它是Tk GUI工具包的標準Python介面[3],並且是Python的業界標準GUI工具包。[4]Tkinter同時也包含在Python的Linux、Microsoft Windows和Mac OS X標準庫中。Tkinter的名字來自Tk interface 原始程式碼 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) bt...

郭俞汝Javascript與Python比較

圖片
全球市場價值最大的銀行 按鈕PUSH增加 按鈕POP執行自訂函數kill 按鈕POP執行kill呼叫其他函數 CSS也可以in-line 寫在這裡成為網頁的一部分,執行後,可以看到,function kill_SHOW執行二指令banks.pop()指令移除banks串列的最後一個元素ABC()去執行函數ABC() 以上所有程式碼 <STYLE>BUTTON{COLOR:PINK;BORDER-RADIUS:20PX;}H1{COLOR:BLACK;BACKGROUND-COLOR:ORANGE;TEXT-ALIGN:CENTER;PADDING:5PX;}</STYLE> <button onclick="ABC()">全球市場價值最大的銀行</button> <button onclick="XYZ()">按鈕PUSH增加</button> <button onclick="kill()">按鈕POP執行自訂函數kill</button> <button onclick="kill_SHOW()">按鈕POP執行kill呼叫其他函數</button> <P id="SHOW" style="BACKGROUND-COLOR:BLUE; FONT-SIZE:24PX;"></P> CSS也可以in-line <script> banks=['摩根大通','美國銀行','中國工商銀行','富國銀行','匯豐銀行','巴黎銀行']; function ABC()  {//第一個函數function ABC() let x = '';//定義字串x內容空白 for (let i in banks)//javascript for loop () python不需要     { x += banks[i] + '<BR>';} //x後...

郭俞汝python串列List(陣列Array),元組Tuple,集合Set,字典Dict

圖片
期中考筆試重點 FONT字型,EM=EMPHASIZE強調   .SELECTOR{用在多個元素},SPAN拇指與小指的距離,一小段,一小段的文字 UL=UNDERER LIST, OL=ORDERED LIST, LI=LIST  push推,美國餐廳放置餐盤的架子下面是彈簧,取盤子pop,放入盤子push append附加在後面, appendix書本的附錄  大括號{ }CURLY BRACKET , CURLY捲,用於PYTHON集合  中括號[ ]SQUARE BRACKET , SQUARE方形,用於PYTHON串列  小括號( )CIRCLE BRACKET , CIRCLE圓,用於PYTHON元組  角括號<>ANGLE BRACKET ,不能直接打角括號,因為它們是HTML命令,需用&符號接LT(小於Less Then)再分號;   圓周CIRCUMFERENCE, 直徑DIAMETER, 半徑RADIUS BORDER邊界, SOLID實心, PX=PIXEL點  PYTHON與JAVASCRIPT命令的對照 ,PYTHON必須透過編輯器或雲端伺服器(例如GOOGLE COLAB)執行,JAVASCRIPT可以直接在瀏覽器CHROME或EDGE執行  PYTHON指令len(串列)對比JAVASCRIPT串列.length;  PYTHON指令串列 .append(新增) 對比JAVASCRIPT串列 .push(新增) ; .SELECTOR{用在多個元素},SPAN拇指與小指的距離,一小段,一小段的文字 UL=UNDERER LIST, OL=ORDERED LIST, LI=LIST push推,美國餐廳放置餐盤的架子下面是彈簧,取盤子pop,放入盤子push append附加在後面, appendix書本的附錄 大括號{ }CURLY BRACKET, CURLY捲,用於PYTHON集合 中括號[ ]SQUARE BRACKET, SQUARE方形,用於PYTHON串列 小括號( )CIRCLE BRACKET, CIRCLE圓,用於PYTHON元組 角括號<>CORNER BRACKET,不能直接打角括...

郭俞汝PYTHON陣列ARRAY串列LIST字典DIC集合SET元組TUPLE

圖片
利用W3SCHOOLS animal = ["豬", "牛", "羊", '貓', "蛇"] #python語言的註解comments,以下命令出現 print(animal[2]) print(animal[-5]) for i in range(5):#其他語言{}代表一個區 x = '我愛' + animal[i] print(x) #使用index print('上面使用index, 下面沒用') for i in animal: print(i) x = animal.copy() print(animal) x.reverse() #將x反轉reverse print(x) animal.append('狗') print(animal) y = animal.copy() y.reverse() #將x反轉reverse print(y) https://steam.oxxostudio.tw/category/python/info/online-editor.html Google Colab ( Colaboratory ) 是一個在雲端運行的編輯環境,由 Google 提供一個雲端虛擬主機,支援 Python 程式及機器學習 TensorFlow 演算法,Colab 目的在提供教育訓練以及教學研究,不用下載或安裝,就可直接編輯 Python,並使用 Python 的資源庫,大幅降低初學者的入門門檻,不用耗費太多時間在環境的安裝與設定。 在 Colab 裡編輯的程式碼,預設直接儲存在開發者的 Google Drive 雲端硬碟中,執行時由虛擬主機提供強大的運算能力,並不會用到本機的資源。但要如果程式閒置一段時間,會被停止並回收運算資源。 520影片參考519 JUPYTER NOTEBOOK人工智慧平台

郭俞汝計算機

圖片
Canvas 計算機 教學影片 FRAME框架SRC=SOURCE來源改成維基百科 維基百科PYTHON說明 Python陣列方法 Method Description append() Adds an element at the end of the list clear() Removes all the elements from the list copy() Returns a copy of the list count() Returns the number of elements with the specified value extend() Add the elements of a list (or any iterable), to the end of the current list index() Returns the index of the first element with the specified value insert() Adds an element at the specified position pop() Removes the element at the specified position remove() Removes the first item with the specified value reverse() Reverses the order of the list sort() Sorts the list python陣列的方法在撰寫模式貼上 Method Description append() Adds an element at the end of the list clear() Removes all the elements from the list copy() Returns a copy of the list count() Returns the number of elements with the specified value extend() Add the elements of a list (or any iterable), to th...

郭俞汝期末考Math.PI與Math.E放入計算機

郭俞汝學習Bro code製作計算機 + 7 8 9 - 4 5 6 * 1 2 3 / 0 . = 刪 ** &#960 e https://www.youtube.com/watch?v=I5kj-YsmWjM Build this JS calculator in 15 minutes!

郭俞汝eval()內建函數data type資料型態

郭俞汝學習Bro code製作計算機 display.value = eval(display.value) disply的vlue用eval(display.value)取代,算是「字串」運算結果 eval()內建函數(方法) in-line線內設定樣式。readonly唯讀read only。電腦的.的接續術性或函數disply.value面板顯示的內容value值 + 7 8 9 - 4 5 6 * 1 2 3 / 0 . = C 郭 俞 汝 https://www.youtube.com/watch?v=I5kj-YsmWjM Build this JS calculator in 15 minutes!