Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2- In the analysis of genes one encounters many problem settings involving searching for certain combinations of letters in a long string. For example,
2- In the analysis of genes one encounters many problem settings involving searching for certain combinations of letters in a long string. For example, we may have a string like gene = 'AGTCAATGGAATAGGCCAAGCGAATATTTGGGCTACCA' We may traverse this string, letter by letter, by the for loop for letter in gene. The length of the string is given by len(gene), so an alternative traversal over an index i is for i in range(len(gene)). Letter number i is reached through gene[i], and a substring from index i up to, but not including j, is created by gene[i:j]. Write a function freq(letter, text) that returns the frequency of the letter letter in the string text, i.e., the number of occurrences of letter divided by the length of text. Call the function to determine the frequency of C and G in the gene string above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres the implementation of the freq function in Python pytho...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started