12 from random import random
15 print "%s: version 1.0" % sys.argv[0]
22 print "usage: python %s fraction infile outfile" % sys.argv[0]
25 fraction = float(sys.argv[1])
29 doFraction(fraction, infile, outfile)
32 def doFraction(fraction, inFileName, outFileName):
33 infile = open(inFileName)
34 outfile = open(outFileName, "w")
40 if random() <= fraction:
47 print "%d / %d = %.2f" % (fractionIndex, totalIndex, float(fractionIndex) / totalIndex)
50 if __name__ == "__main__":