GH avatar Bite 262. GC content

The DNA of all organsims consists of the letters (bases) A, C, T and G. Every organism has a different ratio of these bases, known as the GC content. This information can not only give clues about the origin of genetic material but can also help to determine how closely related some organisms are.

For the given DNA sequences calculate the GC content as a percentage of all (allowed) bases (=percentage of the letters G or C).

Example:
DNA Sequence:
AAAAAAAATTTTTTGGGGCC
A=8, T=6, G=4, C=2, TOTAL = 20
GC content = n(G|C) / n(A|C|G|T) = 6/20 = 3/10 => 30%

For more background info on DNA check out this link.

Login and get coding
go back Beginner level
Bitecoin 2X

74 out of 74 users completed this Bite.
Will you be Pythonista #75 to crack this Bite?
Resolution time: ~28 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 1.6 on a 1-10 difficulty scale.
» You can do it! 😌

We use Python 3.8