Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

178 PYTHON PROGRAM WRITE A PYTHON PROGRAM POST A SCREENSHOT OF RESULT Write a fu

ID: 3730574 • Letter: 1

Question

178

PYTHON PROGRAM

WRITE A PYTHON PROGRAM

POST A SCREENSHOT OF RESULT

Write a function mutate(dna) that returns a copy of the string dna with one of its nucleotide bases (randomly chosen) randomly mutated to a different base.

DNA Sequences

1 # dna.py

2

3 from random import choice

4

5 def complement(dna):

6      result = ""

7      for c in dna:

8              if c == "A":

9                      result += "T"

10            elif c == "T":

11                    result += "A"

12            elif c == "C":

13                    result += "G"

14            elif c == "G":

15                    result += "C"

16    return result

17

18 def reversecomp(dna):

19    return complement(dna)[::1]

20

21 def random_dna(length=30):

22    fragment = ""

23   for j in range(length):

24            fragment += choice("ACGT")

25   return fragment

26

27 def main():

28    for i in range(10):

29            dna = random_dna()

30            print(dna + " " + reversecomp(dna))

31            print(complement(dna) + " ")

32

33 main()

Explanation / Answer

def random_dna(length=30): fragment = "" for j in range(length): fragment += choice("ACGT") return fragment def mutate(dna): result = "" for x in dna: result += x return result def main(): dna = random_dna(14) copy = mutate(dna) print(copy) main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote