(a) For example,
>>> seq = 'GATTACCTGAGCCTAC' >>> (seq.count('G') + seq.count('C')) / len(seq) 0.5
(b) One solution is to create the complementary sequence using
>>> seq = 'ACCTAGGT' >>> seqc = seq.replace('A', 't').replace('C', 'g').replace('G', 'c') .replace('T', 'a').upper() >>> seqc 'TGGATCCA' >>> seqc == seq[::-1] True
Note that this would not be a suitable method for long sequences because each
replace operation generates an entirely new string in memory (recall that
str is an immutable type).