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
| # Spur Gear in Cango and gearUtils-09.js | |
| from browser import document as doc | |
| from browser import html | |
| from browser import window | |
| # 將 document 中 id 為 "brython_div" 的標註 | |
| # 設為與 brython_div 變數對應 | |
| brython_div = doc["brython_div"] | |
| # 將 canvas 標註放入 brython_div 所在位置 | |
| dataurl = "https://gist.githubusercontent.com/mdecourse/0c1bd6c67c7da225cc802354919b6932/raw/1362980d45f75c210f073485d555a566c1780009/cp2021hw1_discussion.txt" |
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 | |
| import random | |
| brython_div = document["brython_div"] | |
| url = "https://mde.tw/studlist/2021fall/1a.txt" | |
| data = open(url).readlines() | |
| # 檢查資料筆數, 第一筆為 title | |
| #print(data) |
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 sympy as sp | |
| # Define symbols | |
| theta1, theta2, theta3, theta4, l1, l3, l4, l6, xb,zb = sp.symbols("theta1 theta2 theta3 theta4 l1 l3 l4 l6 xb zb") | |
| # Define equations, rearranged so expressions equal 0 | |
| eq1 = l1 * sp.cos(theta1) + l3 * sp.cos(theta2) - xb | |
| eq2 = l1 * sp.sin(theta1) - l3 * sp.sin(theta2) - zb | |
| eq3 = l4 * sp.cos(theta3) + l6*sp.cos(theta4) - xb | |
| eq4 = l4 * sp.sin(theta3) - l6*sp.sin(theta4) - zb |
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 urllib.request | |
| from bs4 import BeautifulSoup | |
| import sys, codecs | |
| from pybean import Store, SQLiteWriter | |
| # 將系統輸出語系編碼設為 utf8 | |
| sys.stdout = codecs.getwriter("utf8")(sys.stdout.detach()) | |
| # 表示要讀入的文章檔名為 wed.txt | |
| filename = "wed" | |
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
| cad2021 2a w5 Github 帳號 | |
| 40823143 | |
| 40923101 a40923101 | |
| 40923102 40923102 | |
| 40923103 40923103 | |
| 40923104 409231044 | |
| 40923105 40923105 | |
| 40923106 40923106 | |
| 40923107 40923107 | |
| 40923108 40923108 |
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
| # 根據各班的電腦輔助設計實習課號, 以 Heroku 主機為跳板, 取出修課學員名單 | |
| cad2aurl = "https://nfulist.herokuapp.com/?semester=1101&courseno=0805&column=True" | |
| # readlines() 可以將所讀的資料放入數列 | |
| data = open(cad2aurl).readlines() | |
| # 確認所讀出的資料內容為學員學號數列 | |
| # print(data) | |
| # 設計一個篩選學員學號的函式, 用來安排座號, 但以本班學員順序為主 | |
| def setSeat(firstNum): | |
| # 利用 len() 計算學員總數 | |
| totalNum = len(data) |
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
| # global 可以讓函式中所設定的 x 有效範圍擴及函式外圍 | |
| # 請試著關閉或開啟 myfun() 中的 global x 設定, 就可以了解如何使用 global 關鍵字 | |
| def myfun(): | |
| global x | |
| x = 2 | |
| print(x) | |
| def myfun2(): | |
| print(x) | |
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 itertools import combinations | |
| import random | |
| # 2021 Fall 各班修課人員名單 | |
| cp_a = "https://nfulist.herokuapp.com/?semester=1101&courseno=0766&column=True" | |
| cp_b = "https://nfulist.herokuapp.com/?semester=1101&courseno=0780&column=True" | |
| cad_a = "https://nfulist.herokuapp.com/?semester=1101&courseno=0805&column=True" | |
| cad_b = "https://nfulist.herokuapp.com/?semester=1101&courseno=0818&column=True" |
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
| # Spur Gear in Cango and gearUtils-09.js | |
| from browser import document as doc | |
| from browser import html | |
| from browser import window | |
| import browser.timer | |
| import math | |
| # 利用 html 建立一個 CANVAS 標註物件, 與變數 canvas 對應 | |
| canvas = html.CANVAS(width = 600, height = 400) | |
| # 將 canvas 標註的 id 設為 "cango_gear" | |
| canvas.id = "cango_gear" |
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
| # Draw single Spur Gear | |
| from browser import document as doc | |
| from browser import html | |
| import math | |
| # 利用 Brython 建立 canvas 標註元件 | |
| canvas = html.CANVAS(width = 600, height = 400) | |
| # 將此 canvas 的 id 設為 "spur" | |
| canvas.id = "spur" | |
| # 將 brython_div 變數設為 id 為 "brython_div 的 doc 物件 | |
| brython_div = doc["brython_div"] |