GC Content
Easy · rating 1000 · strings, math
Read a DNA strand (letters A C G T). Print its GC content: the percentage of nucleotides that are G or C, rounded down to a whole percent.
Editorial
GC Content reports the percentage of a DNA strand that is G or C, rounded down — a common bioinformatics measure. Count the G/C bases and scale by 100 over the length with integer division.
gc = sum(1 for c in dna if c in 'GC')
print(100 * gc // len(dna))Complexity
Time: O(n). Space: O(1).