發表文章

目前顯示的是 6月, 2024的文章

林立培期末考

圖片
  from tkinter import * def doSomething ( event ):     #print("You pressed: " + event.keysym)     label . config ( text = event .keysym) window = Tk () window . title ( '林立培期末考' ) window . bind ( "<Key>" , doSomething )   #<, >在網頁表示要使用\<,\> label = Label ( window , font = ( "Helvetica" , 300 ), bg = 'yellow' ) label . pack () window . mainloop ()

林立培LEFT,MID,RIGHT,LEN,IF

  代號,英文公司名稱,中文公司名稱,股價,市值 3 10 17 20 代號 英文公司名稱 中文公司名稱 股價 市值  NVDA,NVIDIA Corporation,輝達,135.58,3.335T 5 24 27 34 NVDA NVIDIA Corporation 輝達 135.58 3.335T 3.335E+12 MSFT,Microsoft Corporation,微軟,446.34,3.317T 5 27 30 37 MSFT Microsoft Corporation 微軟 446.34 3.317T 3.317E+12 AAPL,Apple Inc.,蘋果,214.29,3.286T 5 16 19 26 AAPL Apple Inc. 蘋果 214.29 3.286T 3.286E+12 GOOG,Alphabet Inc.,谷歌,176.45,2.171T 5 19 22 29 GOOG Alphabet Inc. 谷歌 176.45 2.171T 2.171E+12 AMZN,Amazon.com,亞馬遜,182.81,1.902T 5 16 20 27 AMZN Amazon.com 亞馬遜 182.81 1.902T 1.902E+12 META,Meta Platforms,臉書,499.49,1.267T 5 20 23 30 META Meta Platforms 臉書 499.49 1.267T 1.267E+12 TSM,Taiwan Semiconductor Manufacturing Company Limited,台積電,179.69,931.971B 4 55 59 66 TSM Taiwan Semiconductor Manufacturing Company Limited 台積電 179.69 931.971B 9.31971E+11 BRK-B,Berkshire Hathaway Inc.,波克夏黑瑟威,407.95,880.939B 6 30 37 44 BRK-B Berkshire Hathaway Inc. 波克夏黑瑟威 407.95 880.939B 8.80939E+11 LLY,Eli Lilly and Company,禮來藥廠,891.46,847.248B 4 26 3...

林立培串列list元組tuple集合set

圖片
from tkinter import * import random GAME_WIDTH , GAME_HEIGHT = 1000 , 800 SPEED = 200     #時間單位千分之一 SPACE_SIZE , BODY_PARTS = 50 , 3 #左邊變數 assigning value一次改全部 ctrl shift L COLOR = [ "red" , "orange" , "yellow" , "green" , "blue" , "indigo" , "purple" , "pink" ] #0123456 FOOD_COLOR = "white" BACKGROUND_COLOR = "black" class Snake : #類別Snake類別1 Snake     def __init__ ( self ):         self . body_size = BODY_PARTS         self . coordinates = []         self . squares = []         for i in range ( 0 , BODY_PARTS ):             self . coordinates . append ([ 0 , 0 ])         for x , y in self . coordinates :             i = random . randint ( 0 , 6 ) #產生整數亂數0到6             square = canvas . create_rectangle ( x , y , x + SPACE_SIZE , y + SPACE_...

林立培bro code貪吃蛇import module教育學習網

圖片
https://steam.oxxostudio.tw/category/python/basic/import.html 匯入模組 import Module 在 Python 裡,「模組」是一個存在於任意程式碼中的檔案,任何 Python 的程式碼也都可以當作模組使用,透過 import 陳述式,可以引用其他模組的程式碼,進一步使用其他模組的程式和變數,讓程式更精簡更好維護。 改寫自bro code貪吃蛇 from tkinter import * import random #亂數模組 GAME_WIDTH , GAME_HEIGHT = 1000 , 800 SPEED = 200 #時間單位是千分之一秒 SPACE_SIZE , BODY_PARTS = 50 , 3 #左邊變數 assigning value SNAKE_COLOR = "green" FOOD_COLOR = [ 'pink' , 'yellow' , 'orange' , 'tomato' ] #改成串列可以選擇 BACKGROUND_COLOR = "black" class Snake :     def __init__ ( self ):         self . body_size = BODY_PARTS         self . coordinates = []         self . squares = []         for i in range ( 0 , BODY_PARTS ):             self . coordinates . append ([ 0 , 0 ])         for x , y in self . coordinates :             square = canvas . create_rectang...