發表文章

謝孜妤keyevents期末考

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

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

圖片
this=["香蕉","蘋果","櫻桃"] that=("元組","tuple","貓") print(this) for i in range(-2,2): print(i,this[i]) for i in range(-3,3): print(i,that[i])

謝孜妤brp code貪吃蛇random.randint

圖片
a from tkinter import * import random GAME_WIDTH , GAME_HEIGHT = 1000 , 800 SPEED = 200     #時間單位千分之一 SPACE_SIZE , BODY_PARTS = 50 , 3 #左邊變數 assigning value SNAKE_COLOR = [ "red" , "orange" , "yellow" , "green" , "blue" , "indigo" , "purple" ] FOOD_COLOR = "white" 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 :             i = random . randint ( 0 , 6 )             square = canvas . create_rectangle ( x , y , x + SPACE_SIZE , y + SPACE_SIZE , fill = SNAKE_COLOR [ i ], tag = "snake" , width =...

謝孜妤bro code貪吃蛇python snake game

圖片
程式碼 a from tkinter import * import random GAME_WIDTH , GAME_HEIGHT , SPEED , SPACE_SIZE = 1600 , 800 , 2000 , 50 BODY_PARTS = 3 SNAKE_COLOR = "pink" FOOD_COLOR = "blue" BACKGROUND_COLOR = "gray" 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 , ( GAME_WID...

謝孜妤google co-laboratory機器學習

圖片
frame框架,前面要加上i,width寬度,height高度,src=source來源 以上的原始碼 a<iframe width="560" height="315" src="https://www.youtube.com/embed/5Y-Snm4MWcg?si=fgejb_PkCHHSwvLy" title="YouTube video player"></iframe> frame框架,前面要加上i,width寬度,height高度,src=source來源 <iframe width="560" height="315" src="https://en.wikipedia.org/wiki/Collaboratory" title="YouTube video player"></iframe> 利用google co-labor雲端運算執行python程式 http://colab.research.google.com https://zh.wikipedia.org/zh-tw/%E5%BC%A0%E9%87%8F%E5%A4%84%E7%90%86%E5%8D%95%E5%85%83

謝孜妤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("謝孜妤計算機") window.geometry("500x500") equation_text = "" equation_label = StringVar() label = Label(window, textvariable=equation_label, font=('consolas',20), bg="pink", width=24, height=2) label.pack() frame = Frame(window) frame.pack() b...

謝孜妤python視窗建構toplevel與tk比較

圖片
寬度width高度height來源source=src from tkinter import * #從tkinter函式庫輸入所有函式,檔案'window001.py' import time #412單元延續數入time套件 def delete(): #增加自訂函數def delete() List[int(n.get())-1].destroy() #destroy破壞視窗List[索引] window.config(bg='#10ff10') b1=Label(window,text='謝孜妤',font='Arial 100 bold',bg='#10ff10').pack() x=('三','二','一','\U0001F605','\U0001F600','\U0001F4A9') #建立元祖tuple名為x,0,1,2,3,4,5 List = [] #建立串列list名為List window=toplevel() window.geometry('400x200+800+0') window.title('謝孜妤控制原來的視窗') n = StringVar(window) #類別變數 n.set('刪除') op1 = OptionMenu(window,n,1,2,3,4,5,6).pack() bu1 = Button(window,text='刪除選取視窗',command=delete,font='20',bg='blue',fg='white') bu1.pack() for i in range(6): window = Tk() window.title('謝孜妤第%d個視窗' % (i+1)) window.geometry('300x300+%d+%d' % (i*300,i*100)...

謝孜妤tkinter繪圖套件time時間sleep方法

圖片
from tkinter import * #下載程式碼,從tkinter輸入所有函式 import time x=['\U0001F603','\U0001F609','\U0001F607','\U0001F606','\U0001F608'] for i in range(5): window = Tk() #建構視窗,名為window建構一個房子 window.title('謝孜妤第%d個視窗' % (1+i)) window.geometry('300x300+%d+100' % (300*i)) b1=Label(window,text=x[i],font='Arial 250 bold').pack() window1 = Tk() #建構視窗,名為window建構一個房子 window1.title('謝孜妤第%d個視窗' % (1+i)) window1.geometry('300x300+%d+100' % (1+i)) b1=Label(window1,text=x[i],font='Arial 250 bold').pack() window2 = Tk() #建構視窗,名為window建構一個房子 window2.title('謝孜妤第%d個視窗' % (1+i)) window2.geometry('500x500+0+500') b1=Label(window2,text=x[i],font='Arial 300 bold').pack() time.sleep(1) window.update() window.mainloop()

謝孜妤tkinter套件建立圖形使用者介面gul=graphical user interface

圖片
from tkinter import * #下載程式碼,從tkinter輸入所有函式 window = Tk() #建構視窗,名為window建構一個房子 window.title('謝孜妤的python視窗') window.geometry('700x700+70+700') b1=Label(window,text='\U0001F605',font='Arial 300 bold').pack() window1 = Tk() #建構視窗,名為window建構一個房子 window1.title('謝孜妤的python視窗') window1.geometry('500x800+500+800') b1=Label(window1,text='\U0001F607',font='Arial 300 bold').pack() window.mainloop()

謝孜妤python與javascript程式碼對照

圖片
html程式碼 謝孜妤輸入參數 輸入k 輸入m 輸入n 執行自訂函數 重點 alert內建函數,自訂函數abc 謝孜妤輸出結果 CSS=Cascading Style Sheet 單獨放置檔案abc.css與abc.js也可以放在html檔案內,放置在區塊內 css程式碼 h1{background-color: rgb(245, 7, 245); color: white; border: 10px solid rgb(0, 217, 255); text-align:center; padding: 5px} ul{background-color: green; color: white; font-size: 2em;line-height:1.5} input{font-size:24px;background-color:rgb(210, 250, 215);} .monkey{font-size:36px;} out{background-color:pink;color:blueviolet;}/*css的註解 #k{background-color:white;}/*為id的註解 js程式碼 const space=' ', slash='/', backslash='\\', cr='\n'; function row1(k,m){ for(let i=0; i \n';//javascript與c語言的註解// for(let i=0; i '; document.getElementById('out').innerHTML=out;}

謝孜妤python自訂函數迴圈範圍range寫入模式a,x,w,r

圖片
期中考複習拷貝撰寫模式 a write寫入檔案模式mode w=write會覆蓋原有檔案, a=append接續原來檔案, x=create創立新檔案, x與w有何不同? write寫入檔案,預設不換行,換行'\n' print呈現在螢幕,預設換行,不換行end=''。 write寫入用到英文以外的字元(一,a,b)encoding='utf8' vs code是微軟公司開發的免費lde,整合開發環境,intearated development environment 期中考複習拷貝文字模式 write寫入檔案模式mode w=write會覆蓋原有檔案, a=append接續原來檔案, x=create創立新檔案, x與w有何不同? write寫入檔案,預設不換行,換行'\n' print呈現在螢幕,預設換行,不換行end=''。 write寫入用到英文以外的字元(一,a,b)encoding='utf8' ide整合開發環境 教學影片 vs code截圖 ascll a ASCII ( 發音:  / ˈ æ s k i /   ASS -kee [1] , A merican  S tandard  C ode for  I nformation  I nterchange , 美國標準資訊交換碼 )是基於 拉丁字母 的一套 電腦 字元編碼 標準。它主要用於顯示 現代英語 ,而其擴展版本 延伸美國標準資訊交換碼 則可以部分支援其他 西歐 語言 ,並等同於國際標準 ISO/IEC 646 。 美國資訊交換標準代碼是這套編碼標準的傳統命名, 網際網路號碼分配局 現在更傾向於使用它的新名字 US-ASCII [2] 。 美國資訊交換標準代碼是 美國電氣和電子工程師協會里程碑 之一。 ASCII 由電報碼發展而來。第一版標準發布於1963年 [3] [4] ,1967年經歷了一次主要修訂 [5] [6] ,最後一次更新則是在1986年,至今為止共定義了128個 字元 ;其中33個字元無法顯示(一些終端提供了擴充,使得這些字元可顯示為諸如笑臉、 撲克牌 花式等8-bit符號),且這33個字元多數都已是陳廢的 控制字元 。控制字元的用途主要是用來操控已經處理...