發表文章

目前顯示的是 5月, 2023的文章

翁靜茹python視窗程式使用者介面GUI類別class建構正多邊形或星形

圖片
  #翁靜茹python設窗程式設計 from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 from math import * #從函式庫 math 輸入所有 * 方法 class Regular: #定義類別Regular正多邊形或星型 def __init__(self, cx, cy, cr, s, t, c, w): #類別共同的設定 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 * 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*cos(i*self.u)) self.y.append(self.cy + self.cr*sin(i*self.u)) def draw(self): #類別的方法 for i in range( int(self.s * 1.5) - self.t): canvas.create_line(self.x[i], self.y[i], self.x[i + self.t], self.y[i + self.t], fill = self.c, width = self.w) def show(): #畫圖 poly = Regular(cx.get(), cy.get(), cr.get(), s.get(), t.get(), c.get(), w.get()...

翁靜茹phthon迴圈range

圖片
  w3schools學習python w3schools學習python程式碼 #註解劉任昌程式交易python迴圈相當於EXCEL一列 #相當於JavaScript的// for i in range(20,10,-2): print("第" + str(i) + "列") #整數i要和字串相+連,先轉乘字串string指令str 複習EXCEL都會對應到python指令 Max Min Match Index 目標搜尋,學找最佳會參數 運算列表,判斷參數是否可靠、是否一致 使用修飾的CSS指令前後要加style與/style h1 {background-color: purple;color: white; text-align: center; padding: 10px; border: yellow 20px solid; border-radius: 30px;} h2{ border: green 10px solid; border-radius: 20px;text-align: center;} pre {font-family: verdana; font-size: 20px; border: solid 2px blue; line-height: 1.5} 教學影片 013 014