Archive for May, 2018

Palindromes and Python: Let me count the ways

May 9, 2018

I was looking for some simple Python code examples for my four programming kids.  We are going to do a little graphics so they can see Pygame then do some string and number manipulation.  Just some tinkering, nothing super fancy.  Offhand I could not think of anything so as usual I started thinking of something else.

The other day I was subbing for the golf coach and the kids were done with the math assignment in about five minutes.  Most of the class started on other assignments or went to reading.  One boy had his head on his book bag ready to take a nap.  Jokingly I said instead of taking a nap why doesn’t he find out how many palindromes there are from 1 to 1000.  To my surprise he sits up and asked what a palindrome was.  (My surprise was not that he did not know what a palindrome was, but the fact that he sat up and asked.)  I explained what a palindrome was. He gets a piece of paper and starts figuring.  He was not writing them down one-by-one, but was looking for a pattern.  (I have no idea how many palindromes there are from 1 to 1000.  Suppose if I am going to pose these types of things I should know the answer.  Python project.)  Anyway, from there I mentioned Project Euler.  He made an account and started in.  That led me back to Project Euler.  Might be a good place to find some simple Python projects to fiddle with for the class.  Here is problem number 4.

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

That looks like a good Python type project.  I Google “Python palindrome”.  OMG.  Do you know how many ways there are to write a function to identify palindromes?  Many.  Iterative, recursive, built in function, all with their own subset of variations.  I have code snippets up the wazoo, all solving the same problem.  What more could a programming teacher ask for?!  Be still my heart.  Admittedly, this approach may not work with every programing class (Math?  Yuck.) but with some classes and some kids it is a strategy.

Most of the Python palindrome functions are using the Pythonese text manipulation functions involving slicing; colons and brackets.  I do not remember any of these.  It is going to be the “here a book, here is some code, figure this out, tell me what is going on” method of teaching code.  I like it.  I probably ought to figure out all that colon and bracket business again.

For the right students Project Euler is a gold mine for programming ideas.  For other students it would be the end of their interest in programming (Math?  Yuck.).  Finding the right balance and interests is the key.


A little excitement can be bad.

May 1, 2018

Sunday a teacher emailed me that the internet was down in the school.  I wander down to see what happened.  I have two circuits going into the server room.  One circuit was dead which was the one the firewall, router and air conditioner were on.  I moved the minimum needed equipment to the second circuit to get things working until we could find out the problem with the dead circuit.  Our maintenance guy, Josh, started chasing the problem down Monday morning.  He turned off the breaker and started pulling the receptacle apart and got shocked.  He checks with his mutli-meter and no voltage.  He goes back to work on it.  He gets shocked again.  We call an electrician.  The electrician comes in today.  He climbs up the ladder to look above the drop ceiling.  Josh and I hear “Oh shit”.  That is a bad thing to hear from an electrician.  We have melted wires touching the conduit.  It seems we are lucky the place did not catch on fire.  The electrician is pulling new wires as I type.  School techie work is always so interesting.  Especially in a building built in 1922 and all the electrical is an add on.