Archive for December, 2016

December 21, 2016

So I am happily going along with my one Python student teaching him what I know of Python (admittedly not much but it is an “easy” language and I have several books to learn from).  In my naive confidence that I can learn anything I decided to teach/learn more about recursion.  I have this little program that converts base 10 to base 2.

  1. def binary(n):
  2.    if n > 1:
  3.        binary(n//2)
  4.    print(n % 2,end = ”)
  5. dec = int(input(“Enter an integer: “))
  6. binary(dec)

I think I see how this works so we start to tear it apart.  We are OK with the “//” and the “%” operations.  Into the recursive loop we go.  Surprise!  I cannot figure out how it works.  So I do my usual thing when I cannot figure out some code, I throw in some print statements.  This method is tried and true.  It has clarified code for me for many years.

  1. def binary(n):
  2.    if n > 1:
  3.        print(“first”,n)         # added this for testing purposes
  4.        binary(n//2)
  5.        print(“second”,n)  # added this for testing purposes
  6.    print(“third” ,n % 2,end = ”)
  7. dec = int(input(“Enter an integer: “))
  8. binary(dec)

I input 22.  Here is the output.

first 22

first 11

first 5

first 2

third 1second 2

third 0second 5

third 1second 11

third 1second 22

third 0

Lines 1 – 4 are just fine, the recursion loop.  From there it goes to hell in a hand basket.  I do not understand how it even gets to the “second” print statement.  I had to call in the “Pro from Dover”, a friend of mine who teaches programming at the local university.  He emailed me how it works.  Nope.  It still was real fuzzy.  He is going to come over after the break and have a recursion sit-down with my student and I.

I actually like hitting things like this.  If I knew how to do it all what fun would that be?

Are you smarter than a sixth grader?

December 15, 2016

Tuesday in my middle school coding club I introduced the sixth graders to Lightbot.  Lightbot is a little online coding game.  It is a very simple game in concept.  Make the little robot move and jump and when it lands on a blue square turn a light on.  The coding language consists of little drag and drop icons, forward, right turn, left turn, jump, teleport and light on.  If you have too much spare time on your hands and love solving puzzles have at it.  Caution, it can be addicting.  I am happily going through the puzzles on the projector thinking the kids are working them along with me.  I ask one of the kids “Do you understand this one?”  He answers “I finished that one 10 minutes ago.  I am 3 ahead of that one.”  Everyone was ahead of me.  And I could not catch up.  Is there something wrong when a sixth grader can solve the puzzles several times faster than I can?

I went home and had a glass of wine.  Sixth graders cannot do that yet.

Base conversion program: always a good time

December 9, 2016

I only have one student taking my Python course this semester.  He is doing it pretty much independent study because I teach my senior Stats class at the same time.  The format is I lift some assignment from the book or I dream up something that will target what I want him to learn.  He is self-driven so it works out pretty well.  My latest idea to kill several birds with one stone is a program to convert bases.  I only want to convert bases 2, 10 and 16 just to keep it manageable.  It would be a two-part assignment.  The first part would just take the inputs through the usual Python input statement.  The second part would be to build a GUI with tkinter so there would be two sets of three radio buttons to select the conversion.  No big deal.  Should be doable.  There is a learning objective of understanding bases, learning and understanding a new package, the coding aspect and the algorithm development aspect. All reasonable I initially thought.

The student had not dealt with bases in a long time so we did a quick review.  While doing the review I noticed a pattern I had noticed before but diligently ignored before.  Converting from base 10 to any other base is not a big deal.  There is a nice algorithm.  Converting any base to base 10 is no problem.  There is an algorithm.  Converting base 2 to base 16 or the other direction directly is a big problem.  What I had noticed before was on any conversion I had always had base 10 involved.  If I wanted to convert base 5 to base 8 I always converted 5 to 10 and then 10 to 8.  Going directly is not so easy.  For example, convert 42 base 5 to base 8.  Converting the 2 is no problem, it is the ones place and ones are ones so long as the starting base is less than the destination base.  (Going the other direction, bigger base to smaller base is going to require an addition to the algorithm to handle when the ones are greater than the possible values for the destination base.  Convert 47 base 8 to base 5 for instance.  There are not 7 ones in base 5.)  The tricky stuff starts when trying to handle the 5s place.  40 base 5 = what in base 8?   4 * 5 = x * 8.  Still kind of using base 10 but not quite so directly.

As I type this I can see an algorithm taking shape.  The trouble is I do not want to teach the student my algorithm.  What I have to figure out is not the algorithm, but how to teach the student to develop the algorithm.   I am trying to avoid the standard math class teaching process; here is the algorithm as handed down from on high by the mathematics gods, memorize it and use it over and over until you have it ingrained in your memory.  I have a friend that teaches CS at the local university.  He states that his classes are full of kids that can program but almost none of them can solve coding problems.  Thinking and algorithm development are CS requirements.  Two things that kids hate to do and teachers hate to teach.  Both are very hard to learn and teach.

Well back to thinking.  And on a Friday at that.  I am a glutton for punishment.

Google VR. Ohhh, shiny.

December 2, 2016

I admit it, I like shiny objects.  A new shiny object comes along and I have to go look at it and play with it.  I like shiny objects in my programming classes.  Shiny objects attract students.  My latest shiny object is Unity.  I have been poking through the tutorials as mentioned in my previous post and decided this is one of the best shiny objects I have ever seen.  Then I stumbled on Unity with Google VR (Google Cardboard apps).  It is now so shiny it is blinding.  I found this tutorial ( on how to make Google Cardboard apps.  Ohhh, super shiny!!!

Now the question is: is this really programming or Computer Science?  I have to admit that I do not think it is the traditional concept of either.  But oh boy does it get the kids interested in the field.  It gets the kids wondering what else is out there that can take them in interesting directions.  Traditional programming and CS is not for everyone.  Just look at typical class sizes in a high school Java or Python course.  The percentage is real low.  I have said many times I am not training programmers in my classes, I am teaching kids how to learn to program.  (I am not a good enough programmer to teach programmers.)  I want my kids to come out of my classes saying “That was interesting.  Maybe I will take a closer look at CS/programming to see what else is out there.”  Unity is a hook.  Set the hook deep enough and maybe they will stay with it.  With shiny objects like this I can hook a whole lot of kids that normally would never look in this direction.

I will not retire my Python and Java courses, they still have their place for the kids that are really into programming but with Unity and Lumberyard (my next learning project) I can get a whole new population of kids thinking.