GC content correlates with gene density, melting temperature and genome stability, and it varies
systematically between organisms — which makes it a standard first-pass discriminator in
metagenomics and a required input to PCR primer design. It's also a practical lesson in
floating-point output formatting.
Statement
Given a DNA string, compute the percentage of its bases that are G or C.
Print the percentage rounded to exactly two decimal places (for example 60.92).
Your answer is compared numerically with a tolerance of 0.01, so small formatting differences
between Python and R are accepted.
Input — read from standard input
Variable
Type
Description
s
line 1
str
The DNA sequence to measure
1 <= len(s) <= 1000, uppercase A, C, G, T only
These variables are already read for you in the starter code on the right.
Output
float
the GC percentage, rounded to 2 decimal places
Submit also runs your code against 4 hidden test cases.
Hidden inputs are never shown — if one fails you'll get its number and a description of the
mismatch, not the data.
Constraints
1 <= length(s) <= 1000
Uppercase A, C, G, T only — so the denominator is always length(s)