Teacher ask different version of this code please provide that  ''' Problem A DNA: CG Pairs Purpose:This function will take as an argument a string containing a dna strand  Parameter(s):dna Return Value: fraction of dinucleotides  ''' def cg_pairs(dna):     dna_simple = 'AGCTTTCATTCTGAC'     dna= dna.lower()     for i in range (0,len(dna)):         if(dna[i]=='a'or dna[i]=='c'or dna[i]=='g' or dna[i]=='t' ):             continue         else:             print("Error in DNA strand ")             return 0.0     count = 0     for i in range(0,len(dna)-1):         var = dna[i:i + 2]         if(var=="cg"):             count+=1         else:             continue     return (float(count/(len(dna)-1)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 8PE: Write a program that reads in a line consisting of a students name, Social Security number, user ID,...
icon
Related questions
Question

Teacher ask different version of this code please provide that 

'''
Problem A DNA: CG Pairs
Purpose:This function will take as an argument a string containing a dna strand 
Parameter(s):dna
Return Value: fraction of dinucleotides 
'''

def cg_pairs(dna):
    dna_simple = 'AGCTTTCATTCTGAC'
    dna= dna.lower()
    for i in range (0,len(dna)):
        if(dna[i]=='a'or dna[i]=='c'or dna[i]=='g' or dna[i]=='t' ):
            continue
        else:
            print("Error in DNA strand ")
            return 0.0
    count = 0
    for i in range(0,len(dna)-1):
        var = dna[i:i + 2]
        if(var=="cg"):
            count+=1
        else:
            continue
    return (float(count/(len(dna)-1)

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning