Confusion over the forms of programming problems: Mathematics/Physics versus CS

February 26, 2018 at 7:00 am 11 comments

I’m teaching Media Computation again this semester, about 250 students (over 50% female) in a huge lecture hall.  It’s hard to wander the room to answer questions, especially during peer instruction, but we do it anyways.

I’ve been thinking a lot about one question on the first quiz in week #2 of the class.  All my students are Georgia Tech undergraduates but not-CS majors, so, very smart, lots of math and science background, but almost no programming background.

Here was one of the two problems that had the lowest score. Students were to write down what this program would print.

def computeSalary():
  rate = 10.00
  hours = 40
  salary = hours * rate
  hours = 30
  print salary
  increase = 1.00
  salary = hours * (rate + increase)
  print salary

I suspect most teachers would think that this is a pretty standard first semester, even first couple weeks problem. I certainly did. I even discussed almost the exact same program in lecture.

The most common wrong answer was to write only what the second print statement generated. The first print statement was ignored.

During the last 5-10 minutes of the quiz, almost everyone was gone, and I answered lots of questions from the remaining students — picking my way through the narrow aisles in the lecture hall. They were struggling, so one might expect that they would try to get clues by asking questions. This was a problem that they asked lots of questions about.

I was struck by the words that students used when they described what was the one number that they were writing. One told me that the number she wrote down was the “result” of the function. Another told me that that was the “answer.” I came away with the sense that the students were thinking about the program as a mathematics function or a physics story problem.

We often talk about how computer programs might lead to misconceptions for students because of flawed transfer from mathematics. For example, Python functions have mutable data, use the “=” sign in a non-mathematical way, and have side effects. I wonder if the confusion here is about the similarity in form of the problem. Students see a series of equations in math, or a description of a situation in physics, and the answer is a number, an answer, a single result. Not so with programs — it’s a series of statements (like those others), but there may be more than one thing that the program does. We’d need to do real research to see if there is anything to this, not just me noting anecdotal comments from a half dozen students.

Entry filed under: Uncategorized. Tags: , .

What Universities Must Do to Prepare Computer Science Teachers: UTeach leads a multi-university group to grow computing education The Role of Encouragement for Success in Computing Education, and how that differs by demographics

11 Comments Add your own

  • 1. Raul Miller  |  February 26, 2018 at 7:36 am

    It’s probably worth noting that the design of Haskell (and a variety of related languages) has been considerably influenced by exactly this issue.

    Then again, there’s something to be said for letting students run into an issue early on, in a relatively safe manner (with little or no impact on final grade) to help them learn to reason about it.

    But, also, if you’re going to be doing low-level programming (anything where the timing of results matter), this kind of thing is something you do not always want to abstract away. So, for example, interactive programs, music, animation, … tools that a plumber might use (ultrasonic pipe locator, anything that parses camera imagery), …, etc. etc.

    Which is not to say that we don’t have some good abstractions. Callbacks, for example, give you a different context for each “answer” (and defer sequencing to “the implementation” – which, of course, raises an issue when the sequence of callbacks is a part of the problem you need to solve).

  • 2. Mike Zamansky  |  February 26, 2018 at 7:59 am

    Also the confusion between print and return that arises, particularly in repl and interactive environments.

    • 3. chaikens  |  February 27, 2018 at 10:42 am

      Yes, I’ve seen plenty of intro CS students get that mixed up.

  • 4. alanone1  |  February 26, 2018 at 9:23 am

    I’m not a big fan of guessing, so I’ll just point out a possible correlation: between reading code and reading in general.

    There is some evidence that many people don’t actually do what used to be called “reading” when they “read”, but instead employ strategies that sometimes work in multiple choice reading tests (such as the SATs). One of these involves looking at the possible answers, and then searching in the paragraph for possible matches. There are numerous examples to be found in the comments in forums, where many of them indicate that they read inaccurately, often just a few words without the surrounding context.

    Another form of this heuristic is a filtering one in both oral speech and reading, where main words are perceived but context words are not.

    Oral speech expects negotiation to correct sloppiness used for speed. Reading and writing have to be done much more carefully and comprehensively to work for — rather than against — communication. Fluency grants cognitive boons, but things are worse if fluency is not achieved.

    I wouldn’t worry about either math or physics here, but about students trying every shortcut possible to get by without actually doing the work to learn. (I.e. you have to ask “What are the real goals of most ‘students’ ?”)

    • 5. chaikens  |  February 27, 2018 at 11:15 am

      All the above replies make sense to me. Computer science has learned to distinguish concepts of “process” and “(pure) function”; these are also distinguished intuitively in school and everyday life. The erroneous interpretation is a natural guess for what the code was intended for. Maybe more advantage, and greater grading weight should be given earlier, to interpreting into process-like behavior, like a prompt, read, compute and answer dialog. The example program is pretty pointless, except to we who know we must learn to debug silly mistakes and style blunders in our programs. I wonder if a dialog program, with the similar bug, would be correctly analysed by more students at this stage in the multimedia class?

      It is ironic that computing practice education must today also cover functional style programming; indeed Javascript is one of those languages whose design was influenced by functional programming.

  • 6. gasstationwithoutpumps  |  February 26, 2018 at 11:09 am

    In other engineering fields, I see the same “answer-getting” problem, where students expect one number to be all they need, when a design is called for (or, in your example, an analysis that reveals that two numbers are output).

    Alan correctly points out that many students don’t read—neither the book nor the question. They expect to be fed answers (not ideas, answers) in lecture that they can regurgitate on their exams, because that is the main mode their learning has been for years.

    Because I teach bioengineers, I see extreme versions of this behavior, because the biology classes are indeed loaded with cram-and-forget tests of vocabulary memorization.

  • 7. gflint  |  February 26, 2018 at 4:09 pm

    For my high school senior stats course all tests are open book. I do not want them memorizing formulas or methods of solving problems. I want them to be able to find the formula or method. Many of the problems on the test are renumbered examples from the book. If the students would look (not read in detail) in the book the tests would be incredibly easy. They know this. They still refuse to open the book for any reason other than to look at the homework. Even the better students will not read. They want me to tell them how to do every problem in minute detail during lecture. I think math teachers have trained students to expect math to be presented on the board in complete form. They simply have not been taught how to read math. And reading math is work. It requires a lot of effort. Not most students’ strong suit.

    Programming is the same way. Understanding by reading is required.

    • 8. chaikens  |  February 27, 2018 at 11:34 am

      I wonder if the bad habits math teachers instil is an unfortunate side effect of math’s goal to have complete proofs of everything claimed. In advanced math, we students must spend many hours reviewing and reproducing ourselves the arguments presented in order to understand and use them.

  • 9. Katie  |  February 26, 2018 at 4:15 pm

    In many languages methods/function only have one return value and print statements are confined to the main method. (You might not always want a method call to end up printing something.) I can understand if the students made those assumptions for this problem.

    • 10. Mark Guzdial  |  February 26, 2018 at 6:40 pm

      It’s possible. I don’t think it’s likely. These are all non-technical majors (liberal arts, design, architecture, business), and less than 25% have ever programmed before. This is week #3 of the course, and they haven’t used return yet.

      • 11. Bijan Parsia  |  February 27, 2018 at 8:16 pm

        I wonder if you just presented it as a script (i.e., the body of the function as all top level statements) if they’d see it differently. Interesting and easy to test!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Trackback this post  |  Subscribe to the comments via RSS Feed

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 10,184 other subscribers


Recent Posts

Blog Stats

  • 2,053,934 hits
February 2018

CS Teaching Tips

%d bloggers like this: