Archive for March, 2014

Ceiling Staring 101

March 21, 2014

There is a professor at the university teaching the same Python course I am teaching here at the high school.  If the kids sign up they can get dual credit.  I have met him a couple of times and he knows Python really well.  I on the other hand can spell Python.  He is not using any text book so it makes it a little difficult to synchronize the courses in any way.   As a result I like to see what he is teaching and what assignments he is giving his college students so I can use some of them in my course.  The courses need to be somewhat similar to rate the dual-credit classification.  I also want his assignments so I can try to do them.  So far all are well within my capabilities as a beginning Pythonner but I hit one of his that was much more than just interesting.  It is/was a pain in the rear.  I got part of it working and decided the other part was not worth the effort.  Here is the problem.

The goal of this exercise is to write a script that asks the user to enter an integer, and then displays the names of all of the positive integers up to that number.

Example:

Please enter an integer: 3

one

two

three

The challenge is to write a script that will work for “large” numbers. 

I got up to the two digit part working and that was ugly enough.  Figuring the logic to the problem took me quite a while, not because it was particularly difficult but more because there were several possible approaches.  The university prof sent me his solution, which was much simpler that mine, but there was a step in his logic that was simply not obvious and, if not seen, can make the code really ugly.  This sort of points out an important lesson in coding, getting the correct algorithm or logic is usually more important than being an expert in a language.  The code solution for this problem was well within me and my students’ capabilities but that little error in how to solve the problem led to a major can of worms.

Typically when I hit a code solution that is a can of worms (Isn’t “can of worms” an official programming term?  If it isn’t, it should be.) I suspect one of three things: 1. I screwed up and need to start over on the problem, or 2. the problem really is a can of worms or, 3. I do not know enough of a language to solve the program in a nice elegant manner.  At my present knowledge level of Python I usually suspect 3 but in this case it was a 1.

When I hit a can of worms problem I sits and I stares (usually at the ceiling) in an attempt to see another way to solve the problem.  In this case I had a solution; I knew the solution would work so I kind of got hooked into making that solution work.  I did not stare at the ceiling long enough.  It is a lesson I need to impart to my students, not necessarily the ceiling staring part but the think before you type part.  They all want to read the problem (usually incorrectly) and start hammering on the keyboard immediately.  I also need to point out if it is ugly, think more or read more.  It all goes back to problem solving which is by far the hardest thing to teach to a 17 year old.

Today we are going to rip apart one of their assigned problems: Count the number of even digits in an integer.  Since there are several ways of approaching this problem and considering my own “can of worms” issue it would be a good time to discuss programming away from the computer, or Ceiling Staring 101.

Advertisements

A subtle opinion of 1-1 computers in the classroom

March 13, 2014

One of the small schools in central Montana wrote a short request for information on the state techie listserve about how to implement a 1-1 program in their high school.  Oh boy, the cat is out of the bag now.  When it comes to 1-1 I am very opinionated.  It is sort of my pet project and pet peeve.  I feel EVERY high school should be 1-1 and every junior high should be preparing students for a 1-1 program.  1-1 to me means the device is the student’s.  They own it or it is on long term loan.  It should be treated as the device they are going to use in college or on the job.  It goes home with them, it lives in their backpack and if they screw it up they should be shown how to fix it.  The device should be like a textbook, it goes to class every day and if the teacher decides to use it the kid pulls it out.

If the student cannot afford a laptop I loan them one.  Our check out policy is simple.  I put the student’s name on a spreadsheet and from there on it is theirs to do with as they will.  I make the student an administrator on the laptop; they can install whatever they want on it.  When the student is in school the internet is filtered.  Outside the school it is the parents’ responsibility.  When I get it back in the summer I reformat the whole thing and start from scratch.  If it is damaged beyond repair or lost they buy me a new one.  Has not happened yet.  What is interesting is how few laptops I loan out.

It is interesting, and somewhat depressing, how schools lag behind developments in the world.  The military is always fighting the last war; schools are always seem to be teaching material and using methods from fifty years ago (math is like 2000 years ago).  I can still remember high school (hard to believe considering how long ago it was).  The only major difference I can see in the curriculum is the kids do not spend the first two weeks of chemistry learning how to use a slide rule.  Yes, there are now computers in the classroom and the kids turn in assignments typed on a computer.  And yes some teachers have developed methodology that is computer based and have accepted the changes that are required to bring kids into the 21st century.  But in general schools are still in the 1960s.  The computer is treated by many teachers as an inconvenience in their classrooms.  Many teachers can barely use the thing and they have absolutely no inclination to learn.  Their teaching methods have worked for the last umpteen years and they see no reason to change.  Student teachers are taught how to make Power Point presentations, how to use Excel and how to use a Smartboard.  They are not taught how to manage student computers in their classroom or how to take advantage of them.

Computers change the classroom in some interesting ways.  One of our math teachers is what I consider very progressive technology-wise.  He was one of the first in the area to use a Smartboard extensively.  He has since stopped using it.  His students use it.  He teaches from the back of the classroom with a tablet while his students take notes, work at the front of the room or use software at their desks.  He is still not satisfied with how he has integrated the possibilities that student laptops offer his teaching.  He is in a constant search for improvements.  Of course his move to the back of the room has solved another issue with student laptops; he can see what they are actually doing on their laptops.  There is no denying it, the laptops is a huge distracter for the student.  If the lecture is boring, hit YouTube.  Traditional front of the room teaching does not work when the kids have laptops.  The teacher should be able to move around the room freely, not just to help individuals, but to see what is actually on the computer screen.  Stuffing 25 kids in a small classroom makes this impractical.  Rows of desks are not conducive to teacher mobility.

To me teaching is all about looking for ways to improve or change your methodology to keep up with what is going on in the world.  This does not mean jumping on the latest band wagon, but looking at trends and actually seeing ways of integrating them into the classroom.  I do not see 1-1 as a trend for the future, it should have already have happened at least five years ago.  Walk on any college campus or into any office/job to see why.

Schools are starting realize the importance of 1-1 for the kids but I do not think they realize 1-1 is not just getting a device into a kids hands and turning them loose.  1-1 has huge issues: teacher training, student attitudes, classroom management, classroom layout, funding, and simple things like electrical outlets in older school buildings.  These are all trivial compared to designing a modern computer conscious curriculum.  If we get the device into the kids’ hands will the curriculum evolve?  Or is it necessary to build the curriculum first?  My opinion is if we do not get the devices into the kids hands there will be no motivation to evolve the curriculum.  The status quo is just so comfortable to too many.

1-1 should have happened in the past, we need to bring it into the present so the kids have it for the future.

 

 

How hard is programming?

March 9, 2014

In a comment to Alfred Thompson’s blog post on “Any monkey can code” I talked briefly about a simple coding problem “given a list of integers find the sum of the evens (or the odds or the integers divisible by 3 or whatever).  The Python book I am using has a lot of problems like this scattered through it.  How difficult are these problems?  Anyone with experience in programming will think the problem is pretty trivial.  Depending on the language it is 6 lines of code.  Here is my solution in Python.  (There may be a better solution but this is my solution so all you programming brain surgeons out there, lighten up.)

  1. ints = (1,2,3,4,5,6,7)
  2. n = 0
  3. for i in ints:
  4.     if i % 2 == 0:
  5.         n = n + i
  6. print(n)

I took me maybe 5 minutes to come up with this solution, mostly because I am a slow typist.  Now let’s look at what is involved in this little program and how a kid would have problems coming up with a solution.

There are a lot of simple concepts in this little program that all have to work together to get a result.  Starting at line 1 here I am making a single variable equal to a list with bunch of numbers in it.  Kids know what a variable is; they have been dealing with them in math for years.  That still does not mean they have a firm grasp of the idea, and this variable name is more than one character, not allowable in the math world they know.  Programming teachers keep saying use variables that make sense, but variables with more than one letter do not make sense in the math and math is their only close framework at the moment.  There is no previous framework for them to put this weird variable into.  This idea is not a big deal to most kids but in typical teaching fashion we show it one minute and tell them to use it the next.  There are also the little confusers like parentheses or square brackets and reserved words they may not know that they try to use for a variable name.  (Trying to use “sum” was in my learning curve).  So even line 1 is not as simple as it looks.

Now line 2.  “Why do we need to do that?”  “Because we need to define the variable before we use it.”   “How come we do not have to define the ‘i’?”  “Because it is the index variable in the ‘for’ loop and is self defining.”  “Yah, right, whatever you say.”  I can convince the kids of this one fairly easy.

Line 3 is part of the standard programming curriculum.  A nice simple “for” loop with two variables, one of which is a list of numbers and not a number at all, and the other keeps changing.  All with a colon on the end that does some magic.  Simple syntax memorization.  Now I just have to convince the kids this is the right programming doohickey to use.  My students are in at least their second semester of programming so they know the syntax but they still have issues with strategy.  Most can see the need to use a “for” loop.  Since this is the first time they have used lists in “for” loops (Python thing) it does require learning a new capability of the “for“ loop.

Lines 4 and 5 are the money lines.  These are the logic lines that seem to stump most of the kids.  The “if” part is well understood.  From there things can get a little fuzzy for them.  Determining if an integer is even or odd or divisible by something by looking at the remainder seems totally foreign to the kids.  Now that I think about it math curriculum has done some evolving that has eliminated the remainder from the curriculum.  In pre-calculator years the remainder was used a lot.  Long division and fractional answers have sort of gone the way of the slide rule and with it the use of remainders.  Remainders were useful in finding factors and roots of polynomials but those techniques were replaced by the graphing calculator and algebraic computation software.  The kids are just not used to using them.  Now let’s throw in the new operator, mod (or modulus if you prefer), that the kids have no experience with.  They have to remember the % sign means something other than percent.  Then pile it on with a double equal Boolean operator which may also be a new symbol.  That simple “if” statement the kids thought they knew has become a monster.

Line 5 makes absolutely no sense, at least if you have been taking math for the last umpteen years.  There is no way that n can equal n plus some non-zero number.  “Wait, what do you mean that is not an equal sign!  Is too, just look at it!”  An equal sign is an equal sign and the kids know an equal sign.  That stupid equal sign is the bane of programming teachers.  Personally I think this is one of the really big mistakes in programming languages.  That equal sign is confusing and needs to be replaced by some kind of assignment symbol.  I know there are languages that use a <= symbol which is a bit better.

The kids can get line 6 on their own (usually).  They know there has to be an output somewhere.  With Python’s indent format they sometimes get confused what it should be lined up with but they will get it on the second try if necessary.

So how easy is this little program?  From the beginning programmers’ perspective it is anything but easy.  Unfamiliar math, contradictory math caused by ambiguous symbols, new symbols and logic that is vague due to lack of background.  No wonder the kids struggle and some people think programming is more difficult than brain surgery.

Teaching programming is not getting easier.

March 6, 2014

Teaching programming is not getting easier.  When I offered the Python course I had a book in mind.  I figured that would make the course much easier to teach.  Two weeks into the course I switched books for something a bit better written and a bit more comprehensive.  This is actually the first time I have followed a book closely when teaching programming.  I am using the book simply because my Python experience is nil.  I like the book, it does want I think a book should do, gives enough information to learn from but not so much that it holds your hand and does the problem solving for you.  So I like the book.  That solves absolutely nothing.  The kids won’t read it.  If I give the kids an easy (to me at least) problem like “find the sum of the odd integers in this list” I still get the look from at least half the class that I might as well of asked them to build an anti-gravity engine for a flying car.  Teaching syntax is easy.  The kids write the syntax down in their notes or save a code snippet and they have the idea what it does.  Getting from the given exercise to the point where they type relevant code is a whole different story.  I cannot find a programming book that teaches that skill.

Experience has taught me that the average person does not want to think, be it a high school kid or college kid or soldier or your average adult.  Thinking is work and can easily result in failure and embarrassment.  Thinking is hard work.  That step between the given problem and writing relevant code requires thinking, and sometimes lots of it.  This is the point where teachers get the inevitable “but this is too hard” whine thirty seconds after assigning the problem and well before the kid has really tried the problem.

I used to be a math teacher and math has somewhat the same thinking requirements and the same issues.  The big difference is the kids would have 10 home work problems a night, 8 of which were very easy to do so they would do those and ignore the hard ones.  The result would be an 80%.  With math there are a lot of problems with incremental steps of difficulty for almost any new concept.  Those students that can do the 70 or 80% in math survive just fine.  In math I usually have several different teaching strategies for a concept.  I have multiple “gimmicks” for devolving problems to make them easier to solve.  I have other math teachers to ask for new approaches and a whole lot of cool stuff on the internet to use as resources.   Programming on the other hand has diddly.

In programming there are 4 homework problems over the period of a week, none of which are “easy”, and all require some problem solving and thinking.  There is somewhat of an incremental progression to the problems but that step from written problem to code is always a big one.  It is somewhat similar to solving word problems in math, every student’s favorite task.  For programming there are no colleagues available that have as much or more experience to pull teaching ideas from, if there are any other programming teachers at all.  There are no pedagogical resources anywhere online for teaching strategies.  After watching a number (3) of programming teachers teach it seems the teaching strategy is pretty consistent; show and tell and hope.

A kid can do pretty well in high school just with an average memory.  In math memorization of techniques can go a long way.  In programming memorization is a trivial part of the skill set needed to succeed.   The primary skills needed are problem solving, strategizing, devolving problems into sub-tasks, interpreting, and general full bore head scratching.  Those are an absolute bugger to teach, especially to kids that are not all that interested in learning those difficult skills.  I will go out on a limb here and claim the difference from the good students (top 10%) and the rest is the willingness and desire to improve on that list of skills.  I will go way out there and claim that the difference between a great teacher and a good teacher is a great teacher can get a good part of that lower 90% to want to improve that thinking related skill set.  I strive to be a great teacher but I have one little character flaw holding me back – I like programming for the challenge.  This does not equate for about 90% of my students.  So I am back to teaching programming is not getting easier.

Snow days

March 3, 2014

Friday was a snow day.  Monday is going to be a snow day.  In Montana it takes a lot of snow to make one snow day, much less two.  It seems the city has spent the overtime street cleaning budget for the year already so the plows are only working in the daytime.  We are supposed to get 4 to 8 more inches tonight.  The main streets are drivable but the residential streets are getting a bit impassable.  Two-wheel drive cars are restricted to main streets only, if they can get there.

I have caught up with my grading, I have reviewed my lecture notes, I have canceled my University test Friday and then Monday (the course is mostly on-line so no biggie there), so I may have to go snowboarding tomorrow.  That is if I can get there.  Four-wheel drive with studded snow tires, I am good unless it gets real ugly.  It was real ugly this weekend, ten below and windy on the hill.  Not my cup of tea.  I do fresh power and trees, not stupid cold.  It is supposed to be warmer tomorrow, in the 20’s.  Heat wave.  It is supposed to be rain/snow mix starting Wednesday.  Now that is going to make the city real interesting.

I know a number of teachers will be in full panic mode.  They seem to have every day scheduled exactly and if they lose one they have no flexibility in their schedule.  I am at least one week ahead in my really fuzzy schedule so I am golden.  I have never been good at building a daily schedule for classes.  I like to keep things flexible so I can pick up on tangents that interest the students.  This worked great when I was teaching math.  If they were interested in anything we were off on that trail.  In the programming class it is not needed so much.  I leave lots of room in that class.  Some days are just pure work days.  Our classes are an hour and a half long and I cannot lecture that long if I wanted to.  Anybody that lectures that long needs a sock stuffed in their mouth after an hour or so.  Nobody is that good, especially with high school kids (although we have some teachers that try).  The fact I have never taught this class sort of restricts the ability to make a concrete schedule any way.

The news says it is raining on the highway to the ski area.  That means really bad ice.  The ski area is 100 miles away and is usually less than a two hour drive.  Maybe I won’t be snowboarding tomorrow.