This file contains 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
# 2a w3 grouping program, 與 2b 處理架構相同 | |
from browser import html | |
from browser import document | |
import random | |
brython_div = document["brython_div"] | |
# 根據 href 與 content 將 html 元件中的 anchor 插入頁面 | |
def makeLink(href, content): | |
brython_div <= html.A(content, href=href) |
This file contains 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 json | |
from urllib.request import urlopen | |
import os | |
import math | |
USER = "mdecourse" | |
#perpage=30.0 | |
perpage = 100.0 | |
userurl = urlopen('https://api.github.com/users/' + USER) | |
public_gists = json.load(userurl) |
This file contains 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 | |
from browser import document | |
# 使用者可以透過 window 當作介面使用其他 Javascript 功能 | |
from browser import html, window, ajax | |
# https://www.brython.info/static_doc/en/ajax.html | |
brython_div = document["brython_div"] | |
output = html.DIV("output") | |
output.id = "output" | |
brython_div <= output |
This file contains 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 | |
# 導入數學模組 | |
import math | |
# 導入亂數模組 | |
from random import random, randint |
This file contains 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 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 https://github.com/joeyajames/Python/blob/master/bfs.py | |
class Vertex: | |
def __init__(self, n): | |
self.name = n | |
self.neighbors = list() | |
self.distance = 9999 | |
self.color = 'black' | |
def add_neighbor(self, v): |
This file contains 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 document as doc | |
from browser import html | |
import math | |
# 準備繪圖畫布 | |
# 利用 html 建立一個 CANVAS 標註物件, 與變數 canvas 對應 | |
canvas = html.CANVAS(width = 600, height = 400) | |
# 將 canvas 標註的 id 設為 "cango_gear" | |
canvas.id = "chord1" | |
# 將 document 中 id 為 "brython_div" 的標註 | |
# 設為與 brython_div 變數對應 |
This file contains 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
# include <math.h> | |
# include <stdlib.h> | |
# include <stdio.h> | |
# include <time.h> | |
//# include "fem1d_bvp_linear.h" | |
double *fem1d_bvp_linear ( int n, double a ( double x ), double c ( double x ), | |
double f ( double x ), double x[] ); | |
double h1s_error_linear ( int n, double x[], double u[], | |
double exact_ux ( double x ) ); |
This file contains 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
# Iterative Binary Search Function | |
def binary_search(list1, n): | |
low = 0 | |
high = len(list1) - 1 | |
mid = 0 | |
while low <= high: | |
# for get integer result | |
mid = (high + low) // 2 | |
This file contains 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
url = "https://nfulist.herokuapp.com/?semester=1101&courseno=0805&column=True" | |
data = open(url).readlines() | |
print(len(data)) |
NewerOlder