This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from browser import html | |
| from browser import document as doc | |
| import browser.timer | |
| canvas = html.CANVAS(width = 400, height = 100) | |
| canvas.id = "game-board" | |
| brython_div = doc["brython_div"] | |
| brython_div <= canvas | |
| ctx = canvas.getContext("2d") | |
| px = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from browser import html | |
| from browser import document as doc | |
| from browser import timer | |
| canvas = html.CANVAS(width = 400, height = 100) | |
| canvas.id = "game-board" | |
| brython_div = doc["brython_div"] | |
| brython_div <= canvas | |
| brython_div <= html.BUTTON("啟動", id="power") | |
| ctx = canvas.getContext("2d") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Every gist is a Git repository, which means that it can be forked and cloned. If you are signed in to GitHub when you create a gist, the gist will be associated with your account and you will see it in your list of gists when you navigate to your gist home page. | |
| Gist can be public or secret.Public gist show up in Discover, where people can browse new gists as they're created.They're also searchable, so you can use them if you 'd like other people to find and see your work. | |
| Secret gists don't show up in Discover and are not searchable.Secret gists aren't private. If you send the URL of secret gist to a friend, they'll be able to see it.However, if someone you don't know discovers the URL, they'll also be able to see your gist. If you need to keep your code away from prying eyes, you may want to create a private respository instead. | |
| After creating a gist you cannot convert it from public to secret. | |
| You'll receive a notification when: | |
| You are the author of a gist. | |
| Someone mentions you in a gist. | |
| You subscribe to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Gist是Github的一個子服務,且任何人都可以使用這個服務,不論你是否擁有Github帳號。 | |
| 以開發者的角度來說,最基本的功能就是可以分享片段的原始碼。 | |
| 有別於Github的Respository,Gist可以只分享專案中的某一個小檔案中的程式碼, | |
| 且擁有私人的選項,讓別人不會搜尋到你的Gist。 | |
| 在Github的Respository設定Private是要付費的,但在Gist是不需要的。 | |
| 除此之外Gist還有許多用處,包括可以直接執行我們就來一一介紹吧! | |
| 10:40 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| r=10 | |
| for o in range(1,r+1): | |
| l=random.randint(1,18) | |
| i=random.randint(1,18) | |
| print("第"+str(o)+"個紅色方塊座標為("+str(l)+","+str(i)+")") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # source from https://hawstein.com/2013/04/15/snake-ai/ | |
| # snake head is black | |
| # add lightgrey grid | |
| # 從 browser 導入 document 並設為 doc | |
| from browser import document as doc | |
| # 使用者可以透過 window 當作介面使用其他 Javascript 功能 | |
| from browser import html, window | |
| # 用於定時執行特定函式 | |
| import browser.timer | |
| # 導入數學模組 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 從 browser 導入 document 並設為 doc | |
| from browser import document as doc | |
| # 使用者可以透過 window 當作介面使用其他 Javascript 功能 | |
| from browser import html, window | |
| # 用於定時執行特定函式 | |
| #import browser.timer | |
| from browser import timer | |
| # 導入數學模組 | |
| import math | |
| # 導入亂數模組 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| # 圓的半徑 | |
| r = 5 | |
| # 圓心座標 | |
| cx, cy = 4.5, 4.5 | |
| # 10x10 的區域 | |
| for y in range(10): | |
| for x in range(10): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from browser import html | |
| from browser import document as doc | |
| import math | |
| # 利用 html 建立 canvas 超文件物件 | |
| canvas = html.CANVAS(width=400, height=400) | |
| brython_div = doc["brython_div1"] | |
| brython_div <= canvas | |
| # 每一格的 pixel 數 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n = 11 | |
| space = '_' | |
| center = n//2 | |
| #print(center) | |
| for y in range(n): | |
| for x in range(n): | |
| print("(", x, ", ", y, ")", sep='') |
OlderNewer