# PracProg2alg

1.

a.

Iterate over each character in the sequence from the beginning to end, replacing each A, T, G, and C with its T, A, C, and G, respectively.

b.

No!

c.

def complement(sequence): """ (str) -> str Return the complement of sequence. >>> complement('AATTGCCGT') 'TTAACGGCA' """ complement_dict = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'} sequence_complement = '' for char in sequence: sequence_complement = sequence_complement + complement_dict[char] return sequence_complement

2.

a.

index = 0 smallest = L[0] for i in range(1, len(L)): if L[i] < smallest: index = i smallest = L[i]

b.

def min_index(L): """ (list) -> (object, int) Return a tuple containing the smallest item from L and its index. >>> min_index([4, 3, 2, 4, 3, 6, 1, 5]) (1, 6) """ index = 0 smallest = L[0] for i in range(1, len(L)): if L[i] < smallest: index = i smallest = L[i] return (smallest, index)