2026/7/21(二) 19:00-20:30
- 今日教學進度:
- 教師帶領佳恩討論 Khan Academy: Intro to computer science - Python/Unit 5: Automating tasks with lists/Lesson 1: List indices
- 複習 Challenge: DNA mutation Step 1
- 完成 Challenge: DNA mutation Step 2, 3
- 作業指派:
- 請佳恩複習今天學習的學習內容,說明如「今日教學進度」。
- 請佳恩預習Challenge: DNA mutation Bonus。使用 ChatGPT 來探索 Python List 變數的 random.choice 方法中選項的概率,這隨機選項的概率可以用來模擬 Bonus 的情境。
- 下次課程計畫:
- 下次課程日期預計:2026/7/21(二)。 (7/14 FSY)
- 檢閱上次作業派執行狀況。
- 教師指導佳恩寫程註解。
- 教師帶領佳恩討論 Khan Academy: Intro to computer science - Python/Unit 5: Automating tasks with lists/Lesson 1: List indices
- 完成 Challenge: DNA mutation Bonus
- main.py
- import dna
- import random
- # 已知原來的 DNA 序列如下:
- DNA_bases = ["Gua", "Cyt", "Thy", "Gua", "Ade", "Ade" , "Cyt", "Gua"]
- '''
- 因為已知的 DNA 序列中,鹼基代號有重複,
- 故設定指標串列來識別,以利後續處理時不會被同名鹼基混淆
- '''
- DNA_base_indices = [0, 1, 2, 3, 4, 5, 6, 7]
- '''
- 根據 Yui 的解釋:DNA 序列兩端鹼基更容易發生突變。
- 可假定這八個鹼基突變的相對機率權重如下:
- 3,2,1,1,1,1,2,3
- 依此設定 DNA 序列鹼基的權重串列
- '''
- DNA_base_weights = [3,2,1,1,1,1,2,3]
- '''
- 隨機決定 DNA 序列中的鹼基發生突變的數量,
- 限定範圍 2-4 個
- '''
- num_mutations = random.randint(2, 4)
- print("num_mutations = " + str(num_mutations))
- # Randomly mutate num_mutaions of bases in the DNA sequence.
- # 突變串列開始為空串列,在完成 for 迴圈後,應有 num_mutations 個元素
- mutations_indices = []
- for mutation in range(num_mutations):
- # 每一次迴圈,按權重隨機取一個 DNA 突變鹼基的指標,
- mutating_index = \
- random.choices(DNA_base_indices, weights=DNA_base_weights, k=1)[0]
- print("mutating_index = " + str(mutating_index))
- # 將取出的一個突變鹼基附加到突變鹼基串列
- mutations_indices.append(mutating_index)
- print("mutations_indices = " + str(mutations_indices))
- '''
- 從 DNA 序列的指標串列中刪除,
- 以避免在下一迴圈重複取同一個鹼基。
- 同時把對應的鹼基的權重從其串列中一併刪除。
- '''
- position = DNA_base_indices.index(mutating_index)
- DNA_base_indices.pop(position)
- DNA_base_weights.pop(position)
- '''把剩下未突變的鹼基的指標串列顯示出來'''
- print("DNA_base_indices = " + str(DNA_base_indices))
- print("DNA_base_weights = " + str(DNA_base_weights))
- # 進入下一個迴圈
- '''
- 迴圈結束時,突變串列 mutations_indices 中含有 DNA 所有突變鹼基的指標
- '''
- print("Original DNA_bases = " + str(DNA_bases))
- for m in range(len(mutations_indices)):
- '''取出即將突變鹼基的指標'''
- mutating_index = mutations_indices[m]
- '''用指標取出即將突變鹼基的英文代碼'''
- mutating_base = DNA_bases[mutating_index]
- print("mutating_index = " + str(mutating_index) + \
- " mutating_base = " + mutating_base)
- '''呼叫鹼基突變函數代入即將突變的鹼基名稱,得到突變後的鹼基名稱'''
- mutated_base = dna.get_mutated_base(mutating_base)
- print("mutated_base = " + mutated_base)
- '''用得到的突變鹼基名稱改掉原來的 DNA 對應的鹼基,加尾標 x 以利識別'''
- DNA_bases[mutating_index] = mutated_base + "x"
- print("final DNA_bases = " + str(DNA_bases))
- dna.py
- """
- Manipulates nucleotide bases in a DNA sequence, abbreviated as three letters.
- The bases are Adenine (Ade), Cytosine (Cyt), Guanine (Gua), and Thymine (Thy).
- """
- import random
- """
- 為了讓鹼基突變函數真的改變原來的鹼基,
- 這函數必須輸入一個參數代表將要突變的鹼基。
- 然後函數傳回突變後的鹼基,確保和原來鹼基不同。
- 並且根據 Yui 的說明:
- Ade 和 Gua 互變;Cyt 和 Thy 互變。
- 且 DNA 序列兩端的鹼基比中間的鹼基發生突變的機率高。
- """
- def get_mutated_base(mutating_base):
- if mutating_base == "Ade":
- return "Gua"
- elif mutating_base == "Gua":
- return "Ade"
- elif mutating_base == "Cyt":
- return "Thy"
- else: # 一定是 Thy
- return "Cyt"
- Console
- num_mutations = 3
- mutating_index = 2
- mutations_indices = [2]
- DNA_base_indices = [0, 1, 3, 4, 5, 6, 7]
- DNA_base_weights = [3, 2, 1, 1, 1, 2, 3]
- mutating_index = 1
- mutations_indices = [2, 1]
- DNA_base_indices = [0, 3, 4, 5, 6, 7]
- DNA_base_weights = [3, 1, 1, 1, 2, 3]
- mutating_index = 6
- mutations_indices = [2, 1, 6]
- DNA_base_indices = [0, 3, 4, 5, 7]
- DNA_base_weights = [3, 1, 1, 1, 3]
- Original DNA_bases = ['Gua', 'Cyt', 'Thy', 'Gua', 'Ade', 'Ade', 'Cyt', 'Gua']
- mutating_index = 2 mutating_base = Thy
- mutated_base = Cyt
- mutating_index = 1 mutating_base = Cyt
- mutated_base = Thy
- mutating_index = 6 mutating_base = Cyt
- mutated_base = Thy
- final DNA_bases = ['Gua', 'Thyx', 'Cytx', 'Gua', 'Ade', 'Ade', 'Thyx', 'Gua']
- 備用教材:
- GEPT中級聽力AI 生成提示語模板 & ElevenLags TTS Dialogue
- 中文作文:啟承轉合
- 《AI雙語字詞發展策略》
- 字源分析:《旋元佑英文字彙》,單字例句MP3
- 字彙學習:語意場 + 語用場
- 擴展單字策略:字根 vs 50語意
- 《抄寫英語的奇蹟》的 Day9, Day10, Day11。
- 聽力練習:(全文)
- 被動聆聽:習慣發音、語調和節奏。
- 同步聆聽和默讀。
- 口說訓練:(全文)
- 逐句跟唸。
- 同步跟唸。
- 邊唸邊寫。
- 閱讀訓練:(選擇)文章中的句子和段落,進行分析語法、語意、和語用。
- 寫作訓練:(選擇)文章中的句子和段落,進行改寫、換句話說、拆句、併句。
- 擴充單字訓練:(選擇)文章中的字詞,進行語意場分析和造句。
- 《完美英語之心靈盛宴》 的一般使用方法,透過 ChatGPT 生成 1) 換句話說:用不同的說法闡明原短句之涵意,提昇用英文解釋英文的能力,以及用英文思考的能力。2) 造長句:使用不同的結構來造長句,提升應用短句的能力,以及閱讀和寫作長句的能力。3) 語用分析:從某句話推論說話者的意圖和隱含的意思,以及這句話適用的各種情境。
- 《完美英語之心靈盛宴》第84頁 Book1 Part2 Unit6 拒絕失敗。
- Refuse to lose. 拒絕失敗。Refuse to give up. 拒絕放棄。Persistence wins the day. 堅持才會贏。Don't worry about failures. 不要擔心失敗。Worry about missed chances. 擔心錯過機會。Always try, try, try! 永遠嘗試再嘗試。Turn the tables. 反敗為勝。Turn the tide. 扭轉乾坤。 Reverse the situation. 反轉局勢。
- 《完美英語之心靈盛宴》第502頁 Book4 Part1 Unit3 「不要選邊站」。
- Don't take sides. 不要選邊站。Be on everyone's side. 要站在所有人這一邊。Be friendly to all. 對人人友善。Everyone is unique. 每個人都獨一無二。Everyone to his taste. 各有所好。To each his own. 各有所好。Never blame others. 不要責備他。Never point a finger at others. 不要指責他人。It reflects badly on you. 這會為你帶來負面影響。
- 《Heart of the Matter》Part 1 - Chapter 1 第 4-9 段。
