發表文章

賴昀威keyevent期末考

圖片
from tkinter import * def doSomething(event): #print("You pressed: " + event.keysym) label.config(text=event.keysym) window = Tk() window.title('賴昀威期末考') window.bind("&ltKey&gt",doSomething) label = Label(window,font=("Helvetica",200),bg='pink') label.pack() window.mainloop()

賴昀威(集合set)[串列list](元組tuple){字典:dict和集合一 樣但key所以:冒號value值}

圖片
this=["1", "11", "111", "1111", "11111"] print(this) for i in range(-2,4): print(i,this[i])

賴昀威Bro Code貪吃蛇python snake game

圖片
from tkinter import * import random GAME_WIDTH = 1000 GAME_HEIGHT = 700 SPEED = 450 SPACE_SIZE = 50 BODY_PARTS = 3 SNAKE_COLOR = "#00FF00" FOOD_COLOR = "#FF0000" BACKGROUND_COLOR = "#000000" 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_rectangle ( x , y , x + SPACE_SIZE , y + SPACE_SIZE , fill = SNAKE_COLOR , tag = "snake" )             self . squares . append ( square ) class Food :     def __init__ ( self ):         x = random . randint ( 0 , ( GA...

賴昀威google co-laboratory機器學習

圖片
frame框架,前面要加上i,widch寬度,heigh高度, src=source來源 google機器學習實驗 https://colab.research.google.com ">https://colab.research.google.com 以上的原始碼 <iframe width="560" height="315" src="https://www.youtube.com/embed/CLRcLGTIDl0?si=lVsFaG37gq7a5bgg" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> frame框架,前面要加上i,widch寬度,heigh高度, src=source來源 <iframe width="560" height="315" src="https://zh.wikipedia.org/zh-tw/Collaboratory" allowfullscreen></iframe>

賴昀威eval-evaluate函數calculator美國男性印度女生,調色板

圖片
w3schools eval 美國男性 bro code from tkinter import * def button_press ( num ):     global equation_text     equation_text = equation_text + str ( num )     equation_label . set ( equation_text ) def equals ():     global equation_text     try :         total = str ( eval ( equation_text ))         equation_label . set ( total )         equation_text = total     except SyntaxError :         equation_label . set ( "syntax error" )         equation_text = ""     except ZeroDivisionError :         equation_label . set ( "arithmetic error" )         equation_text = "" def clear ():     global equation_text     equation_label . set ( "" )     equation_text = "" window = Tk () window . title ( "Calculator program" ) window . geo...

賴昀威tkinter繪圖套件time時間sleep方法

圖片
程式碼 from tkinter import * #下載程式碼,從tkinter輸入所有函式 import time x = [ ' \U0001F644 ' , ' \U0001F602 ' , ' \U0001F608 ' , ' \U0001F615 ' , ' \U0001F622 ' ] #定義一個串列 y = [] #追蹤特定視窗用途,尚未使用 for i in range ( 5 ):     window = Tk () #建構視窗,名為window建構一個房子     window . title ( '賴昀威python第 %d 視窗' % ( i + 1 ))     window . geometry ( '300x400+ %d +100' % ( 300 * i ))     b1 = Label ( window , text = x [ i ], font = 'Arial 250 bold' ). pack ()     time . sleep ( 1 )     window . update ()     y . append ( window ) #追蹤特定視窗用途,尚未使用 window . mainloop ()

賴昀威python期中考javascript按鈕button事件onchange

圖片
JS程式碼 a const space = ' ' , slash = '/' , backslash = ' \\ ' , cr = ' \n ' ; function row1 ( k , m ){     for ( let i = 0 ; i < k ; i ++ ){         for ( let ii = 0 ; ii < m ; ii ++ ){             for ( let j = 0 ; j < k - i - 1 ; j ++ )                 out += space ;             out += slash ;             for ( let j = 0 ; j < 2 * i ; j ++ )                 out += space ;             out += backslash ;             for ( let j = 0 ; j < k - i - 1 ; j ++ )                 out += space ;};     out += cr ;};}; function row2 ( k , m ){     for ( let i = 0 ; i < k ; i ++ ){         for ( let ii = 0 ; ii < m ; ii ++ ){ ...