# Python Ch5 ###### tags: `python2021` * 要求 (request): * 格式請依照ex1的標準 (檔名:ex5-1.py, ex5-2.py...,最後將所有檔案壓縮至學號.zip or 學號.7z上傳e3) * 輸出檔案內容以TA截圖為標準 # Question 1: DNA translation function The file ***convert.txt*** contains 64 codons and the residues these codons normally encode. Give you a sequence, translate the DNA to protein and print the protein string. ```python= def translate_dna(dna): #write something input_dna = "TCACGACGCGTATATGCATGCGCAGTGCGGCTTTTGAATAAAAGGGGGACATTCGAT" print("DNA sequence: " + input_dna) output_protein = translate_dna(input_dna) print("Protein sequence: " + output_protein) ``` ![](https://i.imgur.com/4tAL8oX.jpg) # Question 2: make change for 18763 (找零錢) You make change for 18763, and just return the minimun amount of coin and bill. ```python= def return_change( money,coin_list ): coin_count=[] #write something return coin_count money=18763 coin=[1000,500,100,50,10,5,1] #bill_and_coin_list print("coin list:\t",coin) print ( "coin you return:\t",return_change(money,coin) ) #1000*18+ 500*1+ 100*2+ 50*1+ 10*1+ 5*0+ 1*3=18763 ``` :::info Hint: 取餘數%, example: 10%3=1, 7%4=3 取商//, example: 10//3=3, 7//4=1 ::: # Question 3: return medium Please write a function that takes a list to calculate and return its medium. Use the following assertions to test your function: ```python= def my_medium(numbers): #write something numbers = [50.9, 50.3, 48.7, 89.2, 60.0, 74.0, 54.2, 101.6, 84.9, 82.1, 79.4, 93.8] assert my_medium(numbers) == 76.7 ``` :::warning Note: Consider the amount of the numbers. ::: # Question 4: GC content Given three DNA sequences, dna_seqs = ["ACGATGTTGCT", "TATTAGTGTCGGCCGCACCGGG", "GTAGGATGATTGT"] Please write a program with a loop in the main program to compute the GC content of them. The computation of GC contents must be done with a user-defined function. ```python= def get_gc_content(???): #write something dna_seqs = ["ACGATGTTGCT","TATTAGTGTCGGCCGCACCGGG","GTAGGATGATTGT"] for ??? in ???: #write something ```