發表文章

楊雅竹python,tkinter,Entry建構輸入工具,pop移除串列元素

圖片
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())#得到bank變數 ABC()#結束XYZ之前給它顯示 def kill(): banks.pop()#pop()移除banks串列的最後一個元素 ABC() tk = Tk()#建構視窗名為tk global bank#宣告廣域變數bank,local是global相反 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...

楊雅竹合開發環境IDE的Jupyter編輯Python程式碼

圖片
SPYDER程式碼 程式碼 from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 banks=['摩根大通','美國銀行','中國工商','富國銀行','匯豐銀行','巴黎銀行'] def ABC(): #畫圖 define自訂函數 global b1 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('三菱銀行') 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) btn2 = Button(tk, text="增加", command = XYZ).pack(side=LEFT) btn3 = Button(tk, text="刪除", command = kill).pack(side=LEFT) tk.mainloop()

楊雅竹Javascript與Python比較

全球市場價值最大的銀行 按鈕BUTTON push增加 pop刪除最後一項 按鈕POP執行Kill呼叫其他函數 CSS也可以in-line 以上javascript與html與css程式碼 <STYLE>BUTTON{GREEN:PINK;BORDER-RADIUS:20PX;}H1{COLOR:WHITE;BACKGROUND-COLOR:PURPLE;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:PINK; FONT-SIZE:24PX;"></P> CSS也可以in-line <script> banks=['摩根大通','美國銀行','中國工商銀行','富國銀行','匯豐銀行','巴黎銀行']; function ABC()  { let x = '';//定義字串x內容空白 for (let i in banks)//javascript for loop () python不需要     { x += banks[i] + '<BR>';} //x後面加上banks[0]....<> document.getElementById('SHOW').innerHTML = x;} function XYZ...

楊雅竹python串列List(陣列Array),元組Tuple,集合Set,字典Dict

圖片
EMBED嵌入影片522 拷貝521連結的期中考重點 .SELECTOR{用在多個元素},SPAN拇指與小指的距離,一小段,一小段的文字 UL=UNDERER LIST, OL=ORDERED LIST, LI=LIST 大括號{ }CURLY BRACKET, CURLY捲,用於PYTHON的集合 中括號[ ] SQUARE BRACKET, SQUARE方形,用PYTHON串列 小括號( ) CIRCLE BRACKER, CIRCLE圓,用於 PYTHON元組 角括號<>CORNER BRACKET,不能直接打角括號因為他們是HTML命令需用&符號接LT(小於Less Then)在分號; 圓周CIRCUMFERENCE 直徑DIAMETER 半徑RADIUS BORDER邊界, SOLID實心, PX=PIXEL點

2025年3月4日上課Python陣列array串列的函數(方法)

利用w3schools練習的python指令 animal = ["豬", "牛", "羊", '貓'] #python語言的註解comments x = animal.copy() print(animal) x.reverse() #將x反轉reverse print(x) animal.append('狗') print(animal) y = animal.copy() y.reverse() #將x反轉reverse print(y)

楊雅竹利用CHATGPT大語言模型產出程式碼

圖片
楊雅竹Canvas 計算機 楊雅竹Canvas 計算機 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 PYTHON陣列方法在撰寫模式貼上 a 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 eleme...

乙班楊雅竹期末考Math.PI與Math.E放入計算機

楊雅竹學習Bro code製作計算機 + 7 8 9 - 4 5 6 * 1 2 3 ÷ 0 . = C π e ** https://www.youtube.com/watch?v=I5kj-YsmWjM Build this JS calculator in 15 minutes!