發表文章

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

胡寬佑python時間函式time.sleep

圖片

胡寬佑python, input, str, float

圖片
VS code編輯環境截圖 VS code程式碼 from math import * def abc(r): print("劉任昌輸入的半徑 " + str(r)) print("圓面積: "+str(pi*r*r)) print("圓周長: "+str(pi*r*2)) print("球體積: "+str(pi*r*r*r*4/3)) print("球表面積:"+str(pi*r*r*4)) def tri(z): print("劉任昌輸入的度 " + str(y)) print("正弦sin "+str(sin(z))) print("餘弦cos "+str(cos(z))) def group(r, t): abc(r) tri(t) r = float(input("輸入半徑: ")) y = float(input("輸入角度360度單位: ")) t = y/180*pi group(r,t) 說明影片 取得連結 Facebook Twitter Pinterest 以電子郵件傳送 其他應用程式

胡寬佑python輸入import數學math函式庫define定義function函數

圖片
from math import * #劉任昌從math輸入所有函式 # import math #劉任昌輸入math函式庫 def abc(r): #定義函數abc print("圓面積: "+str(pi*r*r)) print("圓周長: "+str(pi*r*2)) print("球體積: "+str(pi*r*r*r*4/3)) print("球表面積:"+str(pi*r*r*4)) def tri(z): print("正弦sin "+str(sin(z))) print("餘弦cos "+str(cos(z))) def group(r, t): abc(r) tri(t) r , t = 1, pi/3 #半徑, 60度=pi/3 group(r,t) import math from math import * 心得使用ul=undered list標記語言 輸入函式庫,例如比較 import math from math import all 自訂函數 def 函數名稱() Define Definite當然的 Definition 常常被利用於模組化程式碼 取得連結 Facebook Twitter Pinterest 以電子郵件傳送 其他應用程式

胡寬佑Python類別class函數function

圖片
VS Code截圖 VS Code程式碼 from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 from math import * #從函式庫 math 輸入所有 * 方法 class 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()) polyList.append(...