the implementation of flipplot uses two helper functions the function makeplot contains the code used to produce the plots the function runtrial simulates one trial of numflips coins def makeplot(xvalsyvalstitlexlabelylabelstylelogx falselogy false)"""plots xvals vs yvals with supplied titles and labels ""pylab figure(pylab title(titlepylab xlabel(xlabelpylab ylabel(ylabelpylab plot(xvalsyvalsstyleif logxpylab semilogx(if logypylab semilogy(def runtrial(numflips)numheads for in range(numflips)if random random( numheads + numtails numflips numheads return (numheadsnumtailsdef flipplot (minexpmaxexpnumtrials)"""assumes minexp and maxexp positive intsminexp maxexp numtrials positive integer plots summaries of results of numtrials trials of **minexp to **maxexp coin flips""ratiosmeansdiffsmeansratiossdsdiffssds [][][][xaxis [for exp in range(minexpmaxexp )xaxis append( **expfor numflips in xaxisratios [diffs [for in range(numtrials)numheadsnumtails runtrial(numflipsratios append(numheads/float(numtails)diffs append(abs(numheads numtails)ratiosmeans append(sum(ratios)/float(numtrials)diffsmeans append(sum(diffs)/float(numtrials)ratiossds append(stddev(ratios)diffssds append(stddev(diffs)numtrialsstring (str(numtrialstrials)title 'mean heads/tails ratiosnumtrialsstring makeplot(xaxisratiosmeanstitle'number of flips''mean heads/tails''bo'logx truetitle 'sd heads/tails ratiosnumtrialsstring makeplot(xaxisratiossdstitle'number of flips''standard deviation''bo'logx truelogy truefigure coin-flipping simulation