發表文章

葉榮文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('600x600')#寬度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='purple') canvas.create_line(5, 0, 5, 400, width=5,fill='purple') 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計算現值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 使用到的PYTHON指令 在Spyder開發環境編寫與執行Python 第一個python沒有使用函數def '''PYTHON註解三個單引號或雙引號前後''' r=float(input('利率: '))#input輸入是字串string n=float(input('期數: '))#要計算轉為實數real nubers m=float(input('收付: '))#浮點點float f=float(input('終值: ')) pv = f/(1+r)**n pv += m/r*(1 - 1/(1+r)**n) print('柯文哲計算現值', pv)

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

Javascript在網頁就可以執行不需要開啟Spyder sin執行 cos執行 橫軸

葉榮文python繪製三角函數與powerpoint製作影片

圖片
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=10 # 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 LH(): global x1, y1, z1#global全球,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='green',width=10) if (x2

葉榮文Word File Processing in Python(Python處理Word檔案)

圖片
embed嵌入(bed床,放入床上,嵌入鑽戒) 影片重點 Let's develop brains. 作文,在捷運讓座let給老弱婦孺。 yield (投降, 收益) Yield seats to elderly 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 title was bestowed on him by the Pyt...

葉榮文JAVASCRIPT網頁BUTTON按鈕ONCLICK事件CALL呼叫函數

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