發表文章

黃彥霖python運算CSV輸出TKINTER投資風險與報酬Markowitz

圖片
6/20T程式碼 import csv #輸入csv套件comma separated value f = open('200201to202505.csv','r', encoding="utf-8")#打開下載的檔案SPY.CSV,模式是r讀取, csvreader = csv.reader(f) #將檔案讀入變數csvreader header, rows = list(), list() #宣告空白串列(陣列,清單) firms = set() #建構集合 header = next(csvreader) #串列header儲存檔案第一列 for record in csvreader: #檔案紀錄,逐列row檢視 rows.append(record) #第i筆附加append於rows串列成為rows[i] firms.add(record[0]) #row[0]公司名稱 f.close() #關閉檔案 months = dict() for year in range(2007,2026): months[year]=[str(year*100+month) for month in range(1,13)] count, sum, sumSq, mean, stdev = dict(), dict(), dict(), dict(), dict() for firm in firms: for year in range(2007, 2026): t = (firm, year) #元組(公司,年) count[t] = 0 sum[t] = 0.0 sumSq[t] = 0.0 for row in rows: #字典value增加append元素 for firm in firms: if ro...

黃彥霖類別class __init__(self, 其他參數)

圖片
from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 import math #從函式庫 math 輸入所有 * 方法 from time import * from random import * class Regular: def __init__(self, cx, cy, cr, s, t, c, w): #類別共同的設定必然 def __init__ initiate發起 self.cx, self.cy, self.cr = cx, cy, cr #取得中心座標cx, cy, 半徑cr self.s, self.t = s, t #取得邊角數目s,t尖銳程度,取代原來的k = s.get() self.c, self.w = c, w #取得顏色c,寬度w self.u = 2 * math.pi / self.s #使用模組 math 圓周率 pi self.x, self.y = [], [] for i in range( int(self.s * 1.5)): self.x.append(self.cx + self.cr*math.cos(i*self.u)) self.y.append(self.cy + self.cr*math.sin(i*self.u)) def drawLine(self, x0, y0, x1, y1): canvas.create_line(x0, y0, x1, y1, width = self.w, fill=self.c) def draw(self): #類別的方法 secondTime = second.get() #取得輸入的second變數,當作區域變數secondTime for i in range( int(self.s * 1.5) - self.t): self.drawLine(self.x[i],...

黃彥霖Entry輸入文字變數textvariable字型font

圖片
將OptionMenu改成Entry 將OptionMenu改成Entry完整程式碼 from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 import math #從函式庫 math 輸入所有 * 方法 from time import * from random import * class Regular: def __init__(self, cx, cy, cr, s, t, c, w): #類別共同的設定必然 def __init__ initiate發起 self.cx, self.cy, self.cr = cx, cy, cr #取得中心座標cx, cy, 半徑cr self.s, self.t = s, t #取得邊角數目s,t尖銳程度,取代原來的k = s.get() self.c, self.w = c, w #取得顏色c,寬度w self.u = 2 * math.pi / self.s #使用模組 math 圓周率 pi self.x, self.y = [], [] for i in range( int(self.s * 1.5)): self.x.append(self.cx + self.cr*math.cos(i*self.u)) self.y.append(self.cy + self.cr*math.sin(i*self.u)) def drawLine(self, x0, y0, x1, y1): canvas.create_line(x0, y0, x1, y1, width = self.w, fill=self.c) def draw(self): #類別的方法 secondTime = second.get() #取得輸入的second變數,當作區域變數secondTime for i in range( int(self.s * 1.5) -...

D11117117黃彥霖JavaScript執行輸入字串再反向輸出JS Code編輯Java

圖片
JavaScript輸出結果 黃彥霖輸入字串: JavaScript程式碼 <p>黃彥霖輸入字串:<input id="in" type="text" width="80" /></p> <p><input onclick="f()" type="button" value="黃彥霖執行JavaScript" /></p> <p id="out"></p> <script> function f(){   var a = document.getElementById("in").value;/*取得id=in的文字*/   var b = "源字串: "+a+"<br>長度是:"+a.length+"<br>反串是: ";   var c = "";   for (var i = 0; i < a.length; i++)     c = a.slice(i,i+1) + c ;   b = b +"<font size=7>"+ c+"</font>";   document.getElementById("out").innerHTML = b; } </script> 微軟VS Code編輯Java程式 Java程式碼 import java.util.Scanner ; /*開啟套件package util=utility用途,Scanner掃描器*/ /*黃彥霖utility industry=公用事業產業,電力,自來水,效用=utility */ class Apple {   public static void main ( String [] args ) {     String a , b = "" ;          ...

黃彥霖.JAVAScript金融市場常識

圖片
答 1 2 3 4 下列何者不是金融市場的主要功能? 提供金融工具交易的場所 擔任資金需求者與供給者的橋樑 促進投資活動的效率,提升經濟發展 提供交易者投機的場所 答 1 2 3 4 下列何者不是金融市場交易的工具? 商業本票 銀行存款 股票 房地產 答 1 2 3 4 當金融市場管理的品質較佳時,企業發行的成本會______,金融工具的流動性會______。 較低,較低 較高,較低 較低,較高 較高,較高 答 1 2 3 4 當企業需要資金來進行投資,最好不要用下列何種方式尋求融通? 向銀行借錢 發行股票 發行債券 向地下錢莊借錢 答 1 2 3 4 下列何者不是近年來國內主管機關管理金融市場的發展方向? 減少法規的限制 鼓勵金融創新 對國外資金進行更嚴格的限制與管理 加強國際金融的流通 答 1 2 3 4 在金融市場中主管機關訂定法律規範的目的在於: 增加政府的收入 促進金融市場健全發展與有效經營 增加金融機構的進入障礙 提高金融機構的經營成本 答 1 2 3 4 目前國內監理銀行、票券、證券及保險等金融機構的主管機關為: 財政部 內政部 金融監督管理委員會 經濟部 答 1 2 3 4 依照國內金融監督管理制度的架構,主管證券相關事業的監理單位為: 銀行局 保險局 證券期貨局 檢查局 答 1 2 3 4 依照國內金融監理制度的架構,主掌金融業檢查業務的單位為: 銀行局 中央銀行 中央存款保險公司 檢查局 答 1 2 3 4 下列何者非隸屬「金融監督管理委員會」? 銀行局 公務人員退休撫卹基金管理委員會 證券期貨局 檢查局 答 1 2 3 4 下列何者不屬證券期貨局監理的機構? 投信公司 期貨公司 證券商 保險公司 答 1 2 3 4 下列何者不是檢查局業務檢查的機構? 保險公司 銀行 證券公司 金融資訊服務公司 答 1 2 3 4 下列何者非政府管理金融市...