Harvard:Biophysics 101/2007/02/06:coinflip.py: Difference between revisions
From OpenWetWare
Jump to navigationJump to search
ShawnDouglas (talk | contribs) m New page: {{Template:Harvard_Biophysics_101:2007}} <div style="padding: 10px; width: 720px; border: 5px solid #DDDDFF;"> Here is some template code to get you started. Replace the comments with co... |
(No difference)
|
Revision as of 19:46, 6 February 2007
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(1000):
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]
