🇬🇧 English
In Ask a Space Telescope you used a library called astroquery. It asked NASA for real data. It cost nothing. It needed no key.
There are more libraries like that. Six are below.
This page is a menu, not a full lesson. Each box has one install line and a few lines of code. Copy them. Run them. See what comes back.
Then pick one and go deeper.
🇹🇭 ไทย
ใน ถามกล้องโทรทรรศน์อวกาศ คุณใช้ไลบรารีชื่อ astroquery มันขอข้อมูลจริงจาก NASA ไม่เสียเงิน ไม่ต้องใช้คีย์
ยังมีไลบรารีแบบนั้นอีก ข้างล่างมีหกตัว
หน้านี้เป็นเมนู ไม่ใช่บทเรียนเต็ม แต่ละกล่องมีคำสั่งติดตั้งหนึ่งบรรทัด และโค้ดอีกไม่กี่บรรทัด คัดลอกไป ลองรันดู ดูว่าได้อะไรกลับมา
แล้วเลือกมาหนึ่งตัว ไปให้ลึกกว่านี้
🇨🇳 中文
在向太空望远镜要数据那一课里,你用过一个叫 astroquery 的库。它向 NASA 要真实的数据。不花钱,也不用密钥。
还有别的库跟它一样。下面有六个。
这一页是菜单,不是完整的课。每个方框里有一行安装命令,还有几行代码。抄下来,跑一跑,看看回来什么。
然后挑一个,往深里走。
1 🧬 Biopython — ask a gene bank · ถามธนาคารยีน · 向基因库要数据
🇬🇧 English
NCBI keeps the DNA of many living things. Anyone can ask for it. You give an email, not a password.
NM_000518 is a human blood gene. One letter in it causes sickle cell disease. You can find that letter yourself.
🇹🇭 ไทย
NCBI เก็บ DNA ของสิ่งมีชีวิตหลายชนิด ใครก็ขอได้ คุณให้อีเมล ไม่ใช่รหัสผ่าน
NM_000518 คือยีนเลือดของคน ตัวอักษรตัวเดียวในนั้นทำให้เกิดโรคเม็ดเลือดแดงรูปเคียว คุณหาตัวอักษรนั้นเองได้
🇨🇳 中文
NCBI 保存着很多生物的 DNA。谁都可以去要。你给一个邮箱,不是密码。
NM_000518 是人的一个血液基因。里面有一个字母会导致镰状细胞病。那个字母你可以自己找出来。
install
pip install biopython
python3
from Bio import Entrez, SeqIO
Entrez.email = "you@example.com" # the only "login" there is
handle = Entrez.efetch(db="nucleotide", id="NM_000518",
rettype="fasta", retmode="text")
gene = SeqIO.read(handle, "fasta")
print(gene.description)
print(gene.seq[:60])
Goes with Gene Lab. There you can see what the letters do. ใช้คู่กับ ห้องแล็บยีน ที่นั่นคุณจะเห็นว่าตัวอักษรพวกนี้ทำอะไร 配合基因实验室一起看,那里能看到这些字母在做什么。
2 🛰️ Skyfield — where the space station is now · สถานีอวกาศอยู่ตรงไหนตอนนี้ · 空间站现在在哪里
🇬🇧 English
The telescope lesson asked what was seen. This one asks what you will see.
Skyfield does the sky maths on your own machine. First it downloads a short list of satellites.
If the height is above 0 degrees, the station is up. Go outside and look.
🇹🇭 ไทย
บทเรียนกล้องโทรทรรศน์ถามว่ามีอะไรถูกมองเห็นไปแล้ว บทนี้ถามว่าคุณจะเห็นอะไร
Skyfield คำนวณท้องฟ้าบนเครื่องของคุณเอง ตอนแรกมันโหลดรายชื่อดาวเทียมสั้น ๆ มาก่อน
ถ้าความสูงมากกว่า 0 องศา แปลว่าสถานีอยู่บนฟ้า ออกไปข้างนอกแล้วมองดู
🇨🇳 中文
望远镜那一课问的是已经看到了什么。这一课问的是你将会看到什么。
Skyfield 在你自己的电脑上算天空。它先下载一份很短的卫星名单。
如果高度大于 0 度,空间站就在天上。走出去看看。
install
pip install skyfield
python3
from skyfield.api import load, wgs84
url = ("https://celestrak.org/NORAD/elements/"
"gp.php?GROUP=stations&FORMAT=tle")
sats = load.tle_file(url)
iss = {s.name: s for s in sats}["ISS (ZARYA)"]
here = wgs84.latlon(18.79, 98.98) # Chiang Mai
alt, az, dist = (iss - here).at(load.timescale().now()).altaz()
print("height", alt.degrees) # above 0 = it is up right now
print("compass", az.degrees)
print("km away", dist.km)
Change the two numbers to your own town. Find them in Map Chiang Mai. เปลี่ยนตัวเลขสองตัวเป็นเมืองของคุณเอง หาตัวเลขได้ที่ ทำแผนที่เชียงใหม่ 把那两个数字换成你自己的城市。在画清迈地图里可以找到。
3 🗺️ OSMnx — the real streets of your own town · ถนนจริงในเมืองของคุณ · 你自己城市的真实街道
🇬🇧 English
OpenStreetMap is made by people, and it is free. OSMnx pulls those streets into Python.
The point below is Wat Don Chan. Change it to your own street.
Then ask harder things. How far is the school? Which way is shortest?
🇹🇭 ไทย
OpenStreetMap คนทั่วไปช่วยกันทำ และให้ใช้ฟรี OSMnx ดึงถนนพวกนั้นเข้ามาใน Python
จุดข้างล่างคือวัดดอนจั่น เปลี่ยนเป็นถนนของคุณเองได้
แล้วถามคำถามที่ยากขึ้น โรงเรียนอยู่ไกลแค่ไหน ทางไหนสั้นที่สุด
🇨🇳 中文
OpenStreetMap 是大家一起做的,免费。OSMnx 把那些街道拉进 Python。
下面这个点是 Wat Don Chan 寺。改成你自己的街道。
然后问更难的问题。学校有多远?哪条路最短?
install
pip install osmnx
python3
import osmnx as ox
point = (18.7601, 99.0326) # Wat Don Chan, Chiang Mai
G = ox.graph_from_point(point, dist=1500, network_type="walk")
ox.plot_graph(G, node_size=0,
edge_color="#7ec8ff", bgcolor="#0b1020")
dist=1500 at first. A whole city can take minutes.
ตัวติดตั้งใหญ่ มันพาเครื่องมือแผนที่มาด้วย ตอนแรกให้ใช้ dist=1500 ไว้ก่อน ถ้าเอาทั้งเมืองอาจใช้เวลาหลายนาที
这个安装包很大。它会带一堆地图工具来。一开始先保持 dist=1500。整座城市可能要好几分钟。
Map Chiang Mai uses folium, which draws a map. OSMnx downloads the streets. Do that lesson first. ทำแผนที่เชียงใหม่ ใช้ folium ซึ่งวาดแผนที่ ส่วน OSMnx ดาวน์โหลดถนนมา ทำบทนั้นก่อน 画清迈地图用的是 folium,它画地图。OSMnx 则是下载街道。先做那一课。
4 🌏 ObsPy — an earthquake that shook your city · แผ่นดินไหวที่สั่นถึงเมืองคุณ · 震到你城市的那场地震
🇬🇧 English
There is a seismometer in Chiang Mai. Its name is CHTO. It writes down every shake.
In March 2025 a big earthquake hit Myanmar. People in Chiang Mai felt it. CHTO wrote it down.
This code asks for those fifteen minutes.
🇹🇭 ไทย
มีเครื่องวัดแผ่นดินไหวอยู่ในเชียงใหม่ ชื่อ CHTO มันบันทึกทุกแรงสั่น
เดือนมีนาคม 2025 เกิดแผ่นดินไหวใหญ่ในเมียนมา คนในเชียงใหม่รู้สึกได้ CHTO บันทึกไว้
โค้ดนี้ขอสิบห้านาทีนั้น
🇨🇳 中文
清迈有一台地震仪。它叫 CHTO。每一次震动它都记下来。
2025 年 3 月,缅甸发生大地震。清迈的人感觉到了。CHTO 把它记了下来。
这段代码要的就是那十五分钟。
install
pip install obspy
python3
from obspy import UTCDateTime
from obspy.clients.fdsn import Client
start = UTCDateTime("2025-03-28T06:20:00") # the Myanmar earthquake
stream = Client("IRIS").get_waveforms(
"IU", "CHTO", "00", "BHZ", # CHTO sits in Chiang Mai
start, start + 900)
print(stream)
stream.plot()
5 🔲 qrcode — a code your phone can read · คิวอาร์โค้ดที่มือถือสแกนได้ · 手机能扫的二维码
🇬🇧 English
This one needs no internet at all. It runs on any old school laptop.
Two lines make a picture. Point a phone at it. The phone opens the link.
Put your class page in it. Or put tonight's homework in it.
🇹🇭 ไทย
ตัวนี้ไม่ต้องใช้อินเทอร์เน็ตเลย รันบนแล็ปท็อปเก่าของโรงเรียนก็ได้
สองบรรทัดได้รูปหนึ่งรูป เอามือถือส่องดู มือถือจะเปิดลิงก์ให้
ใส่หน้าเว็บของห้องเรียนลงไป หรือใส่การบ้านคืนนี้ก็ได้
🇨🇳 中文
这一个完全不需要网络。学校里再旧的笔记本也能跑。
两行代码做出一张图。用手机对着它扫一下,手机就打开那个链接。
把班级的网页放进去。或者放今晚的作业。
install
pip install "qrcode[pil]"
python3
import qrcode
img = qrcode.make("https://krueng.ai/")
img.save("mine.png")
print("open mine.png and scan it")
Good next to Put It on the School Wifi. Make the code point at your own app. เข้ากันดีกับ เอาขึ้นไวไฟโรงเรียน ทำโค้ดให้ชี้ไปที่แอปของคุณเอง 和放到学校 wifi 上很搭。让二维码指向你自己的程序。
6 📊 wbgapi — numbers big enough to argue about · ตัวเลขที่ใหญ่พอจะเถียงกันได้ · 大到值得争论的数字
🇬🇧 English
The World Bank counts things for every country. Then it gives the numbers away.
The code below asks one question. How much does each country spend on school?
Thailand, Vietnam and Malaysia, side by side. Five years each.
🇹🇭 ไทย
ธนาคารโลกนับข้อมูลของทุกประเทศ แล้วแจกตัวเลขให้ฟรี
โค้ดข้างล่างถามหนึ่งคำถาม แต่ละประเทศใช้เงินกับโรงเรียนเท่าไร
ไทย เวียดนาม มาเลเซีย วางเทียบกัน ประเทศละห้าปี
🇨🇳 中文
世界银行为每个国家统计数据。然后把数字免费给出来。
下面的代码问一个问题。每个国家在学校上花多少钱?
泰国、越南、马来西亚,并排放着。每国五年。
install
pip install wbgapi
python3
import wbgapi as wb
# SE.XPD.TOTL.GD.ZS = money spent on school, as a share of GDP
table = wb.data.DataFrame("SE.XPD.TOTL.GD.ZS",
["THA", "VNM", "MYS"], mrnev=5)
print(table)
👉 Now pick one · ตอนนี้เลือกมาหนึ่งอย่าง · 现在挑一个
🇬🇧 English
Do not do all six today. Pick one.
Run it. Then change one thing in it. Break it on purpose, and read the error.
Every lesson on this site started that way. Someone ran four lines. Then they asked one more question.
Go back to Start Python when a word here is new. For a seventh library that reads pictures instead of data, try Face Recognition, and its Limits.
🇹🇭 ไทย
อย่าทำทั้งหกอย่างวันนี้ เลือกมาหนึ่งอย่าง
ลองรันดู แล้วเปลี่ยนอะไรสักอย่างในนั้น ทำให้มันพังดูเลย แล้วอ่านข้อความ error
ทุกบทเรียนในเว็บนี้เริ่มแบบนั้น มีคนรันโค้ดสี่บรรทัด แล้วก็ถามคำถามต่ออีกหนึ่งข้อ
ถ้าเจอคำที่ยังไม่รู้ กลับไปที่ เริ่มเขียน Python ถ้าอยากได้ไลบรารีที่เจ็ดที่อ่านรูปภาพแทนข้อมูล ลอง การรู้จำใบหน้าและขีดจำกัดของมัน
🇨🇳 中文
今天别六个都做。挑一个。
跑起来。然后改里面一样东西。故意把它弄坏,再读那条错误。
这个网站上的每一课都是这样开始的。有人跑了四行代码。然后又多问了一个问题。
遇到不认识的词,就回开始学 Python。想要第七个库、读的是图片而不是数据,看人脸识别,以及它的极限。