# Python for fun

With the school year over, I’ve had time to pursue other math related activities.  I’ve been reading through the book Joy of SET by Liz McMahon and others.  It describes the “many mathematical dimensions of a seemingly simple card game” and was recommended to me a few months ago.

There were a few chapters on various probabilities, like the probability of finding 1 set out of 4 randomly chosen cards.  I enjoy writing  python programs that can confirm calculated probabilities by running a simulation several thousands of times.

My program will step through a game of SET, dealing 12 cards, finding SETs and removing them from the table, and dealing more cards so that there are 12 cards on the table again.  If there are no SETs in the dozen cards, then it deals 3 more.

I also wrote a function that will find the probability of finding n SETs when one randomly deals x cards, allowing the user to choose how many times to run the simulation.  I find that 10,000 repetitions is about adequate.

Check out my SET program here.  It’s still a work in progress.  I’m now deciding whether to calculate the expected value of the number of SETs in a dozen cards, which will mean rewriting some of my methods.

Here’s a hack:  if you forget anything in python you can just google it for a refresher.   For example, I couldn’t remember how to set argument defaults for my functions, so I googled:  “python function set default arguments.”

Summertime is a great time for students to follow rabbit holes and exercise python skills.