id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs111fall2019 > gcFreq
prev  |  next  |  chance

Once you have found all the ORFs in a sequence of DNA, the next task would be to determine which ORFs are genes. It turns out that ORFs with a large fraction of nucleotides that are g's and c's are more likely to be genes. Write a function gcFreq(orf) that returns the frequency of all characters in orf that are g’s and c’s. Assume that ORF is a string of dna (i.e. made up of a’s, t’s, g’s, and c’s), and all lowercase. Do not use any built-in functions. Your answer should be a number between 0 and 1. Use the round() function to round your answer to 2 decimal places (this is essential for codingbat to check that you got the right answer). Beware that in codingbat, the default is for division (/) to be interpreted to mean integer division (//). So, to avoid always getting an answer of 0, please multiply your numerator by 1.0 so that codingbat will interpret division correctly.


gcFreq('atggaatgaccatcagtaa') → 0.37
gcFreq('atggaatggaccatcaggtag') → 0.48
gcFreq('atgcgatggatgaccatcaggtgacccccg') → 0.6

...Save, Compile, Run (ctrl-enter)

def gcFreq(orf):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy