13 from random import random
16 print "fraction: version 1.1"
23 print "usage: python %s fraction infile outfile" % sys.argv[0]
26 fraction = float(sys.argv[1])
30 doFraction(fraction, infile, outfile)
33 def doFraction(fraction, inFileName, outFileName):
34 infile = open(inFileName)
35 outfile = open(outFileName, "w")
41 if random() <= fraction:
48 print "%d / %d = %.2f" % (fractionIndex, totalIndex, float(fractionIndex) / totalIndex)
51 if __name__ == "__main__":