# Harvard:Biophysics 101/2007/02/06:coinflip.py

From OpenWetWare

Here is some template code to get you started. Replace the ### comments ### with code to complete the assignment

#!/usr/bin/env python import random # make a list of values for each tally = [0 for i in range(11)] for i in range(10000): coinflip = ### Generate the random 10-mer of H's and T's ### # Use this loop to tally up instances of each k-mer (from 2 to 10) for k in range(2,11): # store a k-mer of H's H = ''.join(['H' for n in range(k)]) Hcount = 0 ### Count up the number of "H" k-mers in this coinflip ### ### See Feb6 assignment for example ### # Update the tally for this k-mer tally[k] = tally[k] + Hcount T = ''.join(['T' for n in range(k)]) Tcount = 0 ### Repeat the above for T's ### tally[k] = tally[k] + Tcount # print out the results for i in range(2,11): print i, tally[i]