Program to keep track of success percentage

Tim Chase python.list at tim.thechases.com
Sat Dec 8 15:59:38 EST 2018


On 2018-12-08 10:02, Musatov wrote:
> I am thinking about a program where the only user input is
> win/loss. The program let's you know if you have won more than 31%
> of the time or not. Any suggestions about how to approach authoring
> such a program? Thanks. --

Can be done with an awk one-liner:

awk '/[wW]/{w+=1}{printf("W: %i L: %i %i%%\n", w, NR-w, w *
100/NR)}END{if (w * 100/NR > 31) print "More than 31% winning"}'

-tkc






More information about the Python-list mailing list