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

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


 * 1) !/usr/bin/env python

import random

tally = [0 for i in range(11)]
 * 1) make a list of values for each

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

for i in range(2,11): print i, tally[i]
 * 1) print out the results