# Python Programs for Beginner Bioinformatics — Part 5

`Input: AAGCCTTTCTOutput: {'A': [1,1,0,0,0], 'C': [0,0,0,2,1], 'G': [0,0,1,0,0], 'T': [0,0,0,1,0]}`
`Input: AACGTACCCGTTCACCTTGGATTATTCCGGOutput: {'A': [1, 2, 1, 0, 0, 2], 'C': [2, 1, 4, 2, 0, 0], 'G': [1, 1, 0, 2, 1, 1], 'T': [1, 1, 0, 1, 4, 2]}`
`def Count(Motifs):    return {symbol: count_array(symbol, Motifs) for symbol in "ACGT"}def count_array(symbol, motifs):   individual_count_arrays = [symbol_count_array_for_single_motif(symbol, motif) for motif in motifs]   return [sum(elements) for elements in zip(*individual_count_arrays)]def symbol_count_array_for_single_motif(symbol, motif):    return [1 if current_symbol == symbol else 0 for current_symbol in motif]`
`Input: AGATCATCAThe Count Matrix:{'A':[1,0,1], 'T':[2,0,0], 'C':[0,2,0], 'G':[0,1,0]}The Profile Matrix:{'A':[1/3,0,1], 'T':[2/3,0,0], 'C':[0,2/3,0], 'G':[0,1/3,0]}`
`def Profile(Motifs):    count = Count(Motifs)    number_of_motifs = len(Motifs)    return {symbol: motif_profile_for_symbol(count[symbol], number_of_motifs) for symbol in "AGCT"}def motif_profile_for_symbol(count_array_for_symbol, number_of_motifs):    return list(map(lambda x: x / number_of_motifs, count_array_for_symbol))`
`Input: AGATCATCAProfile Matrix:{'A':[1/3,0,1], 'T':[2/3,0,0], 'C':[0,2/3,0], 'G':[0,1/3,0]}`
`def Consensus(Motifs):    count_matrix = Count(Motifs)    symbols = "ACGT"    string_length = len(Motifs)    consensus_list = [consensus_symbol_at_index(count_matrix, i, symbols) for i in range(string_length)]    return ''.join(consensus_list)def consensus_symbol_at_index(count_matrix, index, symbols):    count_to_symbols_tuple = {count_matrix[symbol][index]: symbol for symbol in symbols}    max_count = max(count_to_symbols_tuple.keys())    return count_to_symbols_tuple[max_count]`
`def HammingDistance(p, q):    return sum(list(map(lambda x, y: int(x != y), list(p), list(q))))def Score(Motifs):    return sum(map(lambda motif: HammingDistance(motif, Consensus(Motifs)), Motifs))`

--

--