All posts by rwhite

Rip. Mix. Burn.

Thank goodness for CDs. I don’t know how life is going to change once I can’t own my music.

Look, I know that this whole streaming thing is where you live now. I get it. You’ve got a subscription, and you get to listen to what they provide you, available 24-7 on your phone and computer.


Spotify may be working for you, but it’s not working for me. It doesn’t have what I want to listen to.

Sometimes it does, I guess. But sometimes not. The very first song I tried to find on Spotify this evening was Lene Lovich’s New Toy, a classic on KROQ back in the 80s. And near as I can tell it was on Spotify at one point, at least according to this guy’s playlist that he put together. New Toy is grayed out, for some reason, and doesn’t show up in any searches. I guess it’s gone.

Where’d that song go?

You know what’s not gone? The MP3 on my computer that I legally ripped from a CD that I own.

I had a bit more luck finding Pink Floyd’s Meddle album. Well done, Spotify. And Old Hag You Have Killed Me by the Bothy Band. Excellent. I shouldn’t trash them too much for their selection. They’ve got enough to worry about, what with the criticisms regarding their payment to artists.

Spotify has most of what I want, okay, but it doesn’t have everything I want. The Lene Lovich example above is something you’ve almost certainly lived yourself, perhaps on Netflix when you went to watch a show that you’d seen their before, only to find out that some licensing agreement had expired and the show is no longer available. It happens all the time.

So where music is concerned, I’m still buying CDs. I’ve heard some exaggerated rumors concerning the death of physical media, but it’s not dead yet. I’m buying physical media and ripping it on my Linux box to FLAC (of course), transcoding it to MP3s using the Apple app XLD, and living large.

CDs will go away someday, of course, and I’ll have to get my bits elsewhere. But I dearly hope it’s the bits that I’ll be buying, as opposed to a license to temporary access to those bits, revocable at any time.

In related news, Microsoft has been selling digital books via the Microsoft Store since 2012. Cool, yeah? Oh, wait. Microsoft has pulled Books from the Microsoft Store and is planning to offer customers who’ve purchased any ebooks via the Store refunds, as their books will no longer be accessible as of July, 2019.

Oops. Guess the money I paid for those books wasn’t actually a “purchase.” It was a “user agreement.” My bad.

Hang on to your data, folks. And make backups. ;)

Open Source, Open Community

A brief story of sharing educational resources

In the software community, the Open Source movement encourages sharing software freely. Whether it’s “free of charge” (one type of freedom) or “free to use these materials and modify in any way you wish” (a different type of freedom altogether), these people share the work they’ve done and the rights to use their work with the larger community.

In the education community, too, there is a long history of teachers sharing resources with each other. From worksheets to lessons plans, from presentations to assessments, we have all benefitted from the experiences and work of our peers at one time or another.

In my own teaching career I have moved from being a borrower of others’ materials to a creator of my own. Computer programming assignments from Cindi Mitchell, physics lesson plans from Dennis Wittwer, Don Hubbard, and Carol Wawrukiewicz, and pedagogical strategies from Aaron Glimme have all informed what I teach and how I teach. A few years into my career I began developing the confidence to share my own growing expertise with others, and learning how to publish my own materials on the World Wide Web was a turning point. Since then, I’ve been happy to share much of what I do professionally on my course websites, even as my own practice continues to evolve.

For a number of years now, teachers at Poly have been using the school’s internal website, MyPoly, to help organize and manage resources for their students. Some teachers also maintain public-facing websites where that information is available to others outside our community. (See Greg Feldmeth and Craig Fletcher” for examples.) These websites typically don’t share everything a teacher does—test keys and personal student information wouldn’t be appropriate for posting-—but assignments, practice materials, and even homework solutions might be found.

It’s not unusual for a teacher who shares materials to receive emails like this:

Hello Mr. White!

I’m teaching AP Physics 1 for the first time at Crescent Valley High School, in Corvallis, Oregon.

I came across your website while searching for materials to use for a pre-assessment.

Would it be all right with you if I include some of your questions in the document I give to my students? I’d be happy to return the favor at some point if it’s ever useful.

Thanks in advance and I hope the new year is treating you well.

Take care,

DB Science Department Crescent Valley High School

Occasionally a student will write asking for assistance of one kind or another. I received one such request from a student in Maryland just after the Thanksgiving Holiday in November, 2018.

Hello Mr. White,

My name is Zeke Nohr, a senior at Aberdeen High School. Over the brief Thanksgiving break, our physics teacher resigned very unexpectedly. The school in the process of finding a replacement for him but as of now, me and 5 other seniors who are very skilled and interested in physics have been placed in charge of planning the curriculum for his physics classes. Two of the classes are AP Physics C: Mechanics which we all took last year so we have all the resources we need for that. The other two are AP Physics C: E & M which we are currently enrolled in. We have some resources that our teacher left behind but we are missing practice tests we would like to use as review materials, especially since we plan on having our next test on Monday or Wednesday next week. Our previous physics teacher frequently used the “Multiple-Choice Practice Problems” from your website,, that are displayed with all units. I do not see a way to download these as a document to distributed to our class. If you have those documents available for the Electricity and Magnetism Units, we would be extremely grateful if you could provide us with a copy.

Best Wishes,

Zeke Nohr

I replied, with instructions on how the student could access some of those problems, and provided links to some practice tests that I post online for students, and got a quick reply.

Hello Mr. White,

Thank you so much for taking time to respond to my email and providing me and my fellow students with resources we can use for the rest of the year in our physics class. We are extremely grateful for your help during this transition.

Thank you,

Zeke Nohr

When I shared the story with Craig Fletcher, he thought that he might have some materials that the students would benefit from as well. In a separate email, he sent along his own set of links.

We didn’t think much more of it until we each received an email the day before Winter Break:

Dear Mr. White and Mr. Fletcher,

Hello, this is Zeke Nohr from Aberdeen High School. I sent you an email around the end of November asking for practice tests resources for our physics classes that me and two other students were teaching due to the unexpected departure of our physics teacher. Mr. White first sent me some great practice tests which were extremely helpful and we are all very thankful for your generosity. When Mr. Fletcher sent me the email saying the two of you had discussed it and shared the plethora of resources on your website, including lectures, textbook links, practice tests, and homework problems and solutions, we were all surprised and excited by your generosity and willingness to help us through a difficult time. Luckily, a new physics teacher was found very quickly and he started here on Monday. His name is Viktor Polyak and he recently graduated from college and this is his first time teaching. He is very good at explaining the topics and all of us here at the school like him. Since he is a first time teacher, he didn’t have any teaching resources when he came in so we have been using the lectures that the two of you supplied and they have been so informative and helpful to us (the mechanics classes have especially enjoyed “The Island Series” at the beginning of Mr. Fletcher’s lectures) and we intend to keep using them for the rest of the year. Having these resources has made the transition to a new teacher so much easier as he does not have to spend time looking for lectures and homework problems and can focus on helping us learn. We are all extremely grateful to the two of you for sharing your resources with us in a time when we did not have access to any. Your generosity and compassion is heartwarming and has made a huge impact on us here. I told the other students here that I was sending a thank you email today and some of them wanted to sign the email as well to show their gratitude.

Thank you so much,

The email was signed with the names of 42 students, the school’s program director, and the new physics instructor, Victor Polyak.

Teachers at Polytechnic School find lots of ways to become involved in our community of learning. We are involved with consortiums and cohort groups, we attend workshops and conferences, we teach at summer school or Partnership for Success!, and we work with teaching fellows and mentor new teachers. For me, making course materials I’ve developed available online where they can serendipitously benefit students and teachers in an even broader community has been a rewarding part of my professional life.

Homemade Capture-the-Flag, part 2

In the last post I was talking about the Homemade Capture-the-Flag competition that I’d created for my students as part of a culminating, end-of-semester activity. Students, working in teams, used their computers and technological/programming skills to solve a series of puzzles that I’d created for them.

As mentioned before, there are two main challenges in implementing the CTF: first, the creation of the problems themselves, discussed in the last post. The other challenge is programming the infrastructure that will manage the competition: the delivery of problems, solution submission, scoring, and leaderboard updating.

To do this, I leveraged some of my website, PHP, and MySQL skills to create the small website that students would use to log in, read problems, submit answers, and access the leaderboard.

The MySQL database consisted of three tables that teams of students would interact with. There is the users table which included their a user_id (a primary key), a team name (identified by the email field in the screenshot here), a hash of their password (pass, and the time/date of the team’s last login.

The second table was the problems table, with fields for the problem_id, the problem_num, the problem itself (statement, the correct answer, and the points awarded for successfully solving the problem.

Finally there was the successes table which identified for each problem successfully solved the success_id, the problem_id, the solver_id of the problem, and the time it was solved.

Manipulating these three tables with various queries allowed the site to display the Leaderboard with a running total for all teams: SELECT, SUM(problems.points) from users, problems, successes WHERE successes.solver_id = users.user_id AND problems.problem_id = successes.problem_id GROUP BY users.user_id ORDER BY SUM(problems.points) DESC

For people who have worked with PHP, MySQL, and querying databases, putting together this kind of thing can range in difficulty from a trivial activity for an afternoon to a week-long exercise in PHP debugging hell. For myself, it was just enough of a challenge for me that I found the process to be entertaining and engaging.

If you are not a PHP/MySQL person and don’t have any experience with writing “normalized” databases, you may be wondering whether or not it would be possible to find some way to avoid this whole “build an entire database-driven website just so students can solve a few puzzles.” These are just puzzles, of course, each with a simple answer that a student could submit on paper or whisper in your ear. You’re still almost certainly going to have to deliver computer-based problems by computer, however—a 6MB text file for students to search through, for example, is not something that you can hand out on paper—and without the database, there’s no practical way to create a live leaderboard indicating who is in the lead at any point. For a do-it-yourself CTF, I’d strongly recommend finding a way to make the website experience happen.

If you don’t decide to conduct your own Capture the Flag event, however, there are a number of publicly available competitions for high school-aged students that will work for your students. A quick search online will yield results for CTF events and their corresponding schedules.

I encourage all Computer Science teachers to give these activities a try, and consider making them a part of your curriculum.

Homemade Capture-the-Flag Competition, part 1

Happy New Year, everybody!

Just before school got out for the winter break, our school provided some time in the form of “block days” during which teachers could administer mid-year assessments.

I’m currently teaching two Computer Science classes—a single-semester Introduction to Computer Science taught using Python and a one-year AP Computer Science A course taught using Java—and in addition to a one-hour written assessment for each of those classes, I gave them a performance-based Capture the Flag-style assignment to complete as well.

A digital Capture the Flag competition is one which participants attempt to solve a variety of technology-based puzzles, challenges which are often based on hacking, or decrypting, or programming a solution to a problem.
With the exception of one or two students, nobody in these two classes had participated in something like this before, so I was sensitive to the idea of providing a few easy problems to get them started on things.

I also wanted to provide a variety of problems: some that would require programming a solution, some that would require converting from binary to decimal/hexadecimal/ASCII text, some that would require moving out onto the campus to find a hidden clue or “rogue wifi access point” (that I’d placed there with the permission of our IT team).

Having participated in a couple of CTF challenges myself, I also knew that one of the things that can be inspiring is seeing one’s score updated as challenges are solved, along with a leaderboard to let you know how you’re progressing compared with others.

I also wanted to try to ensure that teams had enough members that they could both support each other as needed, but also dole out responsibilities if they wanted to divide-and-conquer the problems they were working on. At the end of my verbal instructions, I ran a program that randomly assigned them to their groups.

There are two significant challenges for a teacher in implementing something like this: one is the creation of the problems themselves, and the other is programming the infrastructure that will manage the CTF: the delivery of problems, solution submission, scoring, and leaderboard updating.

Writing problems turns out to be mostly do-able, especially for anyone who has been teaching CS for awhile. A list of the challenges that were part of this most recent CTF:

  1. Hide and seek – Every page that you look at on the Internet is displayed according to code. Most web browsers have some means of allowing you to view the code that they use to display a page.

    Figure out how to see this code in your web browser, and then take a look at this page (which linked to a page with a lot of tildes, only one of which was an actual link to a page where the key was hidden).

  2. Content vs Style – Some people prefer to focus on creating content, and others like to emphasize their style. What sort of style do you like for your web pages? (The link led to a webpage with a link to an external CSS sheet, in which was hidden the key.)
  3. cd, ls, cat – I don’t know who came up with this idea, but these folders, randomly named, seem to go on forever. Log on to the server and see if you can find a flag in /home/rwhite/Public/directories. (Buried inside a series of randomly-named folders was a file with the key in it.)
  4. Chips Ahoy – I do love a good cookie now and then. Have you seen any on this website? (The competition website had placed a cookie in their browser, which they could identify (if using Chrome or Firefox).
  5. Indigo and Orange – What does that poster, hanging in Poly 110, mean? (A series of alternating colors represented 0s and 1s, which in turn were ASCII codes for the letters for the key.)
  6. Encapsulated data – A graphics file can contain all sorts of interesting information… (The linked-to file had appended to it a text value for the key, which could be identified with a hex analysis using hexdump or some similar tool.)
  7. Number Guessing Game – Well this is interesting. (The link led to a script running on the server that would take numerical input, and then produce a binary output that would guide the solver to closer and closer values until the correct number was entered, revealing the key.)
  8. Sowpods – The game of Scrabble has a collection of legal words that its players abide by. What is the highest scoring word that consists of only letters with odd-numbered point values?

    ‘cab’ has a value of 3 + 1 + 3 = 7, for example, but you can do better than that. Enter your flag in lower-case letters.

  9. Luhn and done – A list of stolen credit card numbers has been leaked on the Internet. You wouldn’t want to get caught using a false CC number (although you probably wouldn’t want to get caught using a correct stolen CC number either).

    Which number in the list is clearly a false CC number?

  10. Pirates Occupy Haaga – Somewhere on the Poly campus is a rogue wifi access point, operating without authority. Use your smartphone or computer to locate that access point, open a web browser, and retrieve the key you’re looking for.
  11. Taste the Rainbow – Just because I can’t brute force your password doesn’t mean it’s secure. If it’s a weak password, it’ll show up in a rainbow table somwhere.
    is the hash of my not-as-awesome-as-I-thought password.
    The flag for this problem is my password.
  12. Circular Primes – The number, 197, is called a circular prime because it and all rotations of its digits—197, 971, and 719—are themselves prime.

    There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.

    How many circular primes are there below one million?

There are always a few hiccups when writing problems. It’s nice to have other people double-check your solutions to make sure that you’ve gotten the answers correct. (I had an error in the first iteration of the rainbow table problem.)

Also, I’d intended the Circular Primes problem to be a programming exercise—I’d first heard of this problem from the awesome website. But because of the fact that other people have discussed this very problem on the Internet, it’s pretty easy to Google an answer, so this problem turned from a programming challenge to a searching challenge. Not what I intended, but I’d already asked them to Google stuff on the Internet to assist them (the Luhn algorithm and the rainbow tables problem given previously) so I just had to go with it.

Once you have some problems, you have to find a way to administer those problems… and that is the far more significant challenge. :)

We’ll save that for the next post.

Project: Raspberry Pi Kiosk Display

If you’ve got a Raspberry Pi lying around and you were wondering about what you might do with it, consider using it to drive a presentation kiosk.

This post doesn’t describe how to set up a Raspberry Pi from scratch. Getting a new Raspberry Pi up and running requires a collection of materials and a bit of time, which is the price one pays for being able to buy a $35 computer. There are a wide variety of tutorials on the web describing how to make that happen, including this YouTube presentation by yours truly.

Assuming you’ve already got your Pi running, though, here’s how you can set up a presentation kiosk that will cycle through a slideshow.

1. Create and test your presentation using LibreOffice Impress software. You can do this on a separate machine running LibreOffice or on the Raspberry Pi itself. You’ll want to set up the slide transitions and the presentation repeat. (Also, if you’re using images in your presentation, be careful of using high-resolution images. I’ve had presentations choke to a halt when given too many high-res images to present.)

2. Using the terminal, download and install xscreensaver.
$ sudo apt install xscreensaver
This is the only way most people have found to reliably keep the screen from sleeping while you’re using your Raspberry Pi in a kiosk mode. Once the software is installed, you can disable the screensaver in the Accessories settings.

3. The system is now effectively running as a kiosk, although you have the Raspberry Pi, the mouse, the keyboard, and a tangle of wires all over the place. To clean things up a little, get some 3M Dual Lock reclosable fastener tape and put one strip on the Pi housing and one on the back of the monitor. You can attach the Pi to the back of the monitor now, and get it up and out of the way.

4. Once you’ve got the display set up and running in a desired location, go ahead and unplug the keyboard and the mouse from the Pi. That way it will be harder for the presentation to be accidentally interrupted.

What can you use this project for?

  1. Showcasing student work
  2. A vehicle for student investigation of the Raspberry Pi or Open Source software
  3. Presenting program information to visitors at Open House or Back-to-School night


Open Sourcing

Fun story.

For my own use and as a programming activity, I wrote a little Python script that I could use as a countdown timer. (Bonus feature: I can run multiple timers at the same time. Apple iOS, I’m looking at you!)

I wanted to have a little bell that would ring at the end, and look at that, GarageBand has a little alarm bell sound! Here it is:

I was going to throw my little project up on GitHub as an example for my students; also, because I’m A Developer. I was pretty sure I wouldn’t have a problem packaging Apple’s alarm bell sound with that project. I mean, I’d already had to go to the mat with Google/YouTube about a song I’d made using some of Apple’s sound loops, and I’d done my research. At just under 30-thousand words (at that’s only for the English version) you can polish off GarageBand’s User License Agreement in an easy afternoon, and here’s the good news about GarageBand projects:

H. GarageBand Features and Support.
Except as otherwise provided, you may use the Apple and third party audio loop content (“Audio Content”), contained in or otherwise included with the Apple Software, on a royalty-free basis, to create your own original soundtracks for your video and audio projects. You may broadcast and/or distribute your own soundtracks that were created using the Audio Content…

Cool! Oh… but wait….

…however, individual samples, sound sets or audio loops may not be commercially or otherwise distributed on a standalone basis, nor may they be repackaged in whole or in part as audio samples, sound libraries, sound effects or music beds.

Dammit, Jim. I can’t use that file in my project. Oh, and maybe I just violated the license by embedding that file here.

What should I do for my project? Quick fix: borrow a desk bell from the Theater Department at school, record a single “ding!” and process it using open source Audacity (“Screw you, GarageBand.”), et voila:

My project–including that alarm bell!–has been posted on GitHub: . Mischief managed.

For the record, I totally get why the GarageBand license agreement would restrict redistribution of files. It’s just another in a long list of Apple-related frustrations for me and I needed to vent a little.

Plus, I wanted to play you my bell recording. I’m quite proud of it! ;)

Quitting Facebook

I quit Facebook last month.

It wasn’t a rage-quit, or a “I’ve had it!” kind of thing. For me, the thing has just run its course. FB has little value to me at this point in my own life, and although I used to maintain the account to keep in touch with alumni, a lot of them aren’t using it anymore either.

There were a couple of precipitating events, perhaps, that did nudge me closer to the precipice. There was a tone-deaf Mark Zuckerberg being interviewed by Kara Swisher a few months ago. There was a phone call from an old friend a few weeks ago who let me know that she isn’t on Facebook, reminding me that such a thing was possible.

Knowing a little bit about how these things work, I’ve been bothered for years by the algorithmic manipulation of your News Feed. Facebook doesn’t display items in your feed in chronological order—it displays them in an algorithmically-generated “Top Items” order which (until very recently) you had no control over. If you’ve every wondered why you haven’t seen some friends’ posts on Facebook, it may well be that their comments were buried so far down in the algorithm that Facebook effectively never showed them to you, in favor of sponsored ads for socks from Sweden.

Last month I read this interview with Yuval Noah Harari, and it really resonated with me. Although the focus of the article wasn’t social networking, there was some discussion of technology and how we respond to it emotionally.

An excerpt:

I try to be very careful about how I use technology and really make sure that I’m using it for the purposes that I define instead of allowing it to kind of shape my purposes for me. That sometimes happens when you open the computer: you have a couple of minutes to spare, so you start just randomly browsing through YouTube, and two hours later, you’re still there watching all types of funny cat videos, car accidents, and whatever. You did not say to yourself, “Okay, I want to spend the next two hours watching these videos.” The technology kind of dictated to you that this is what you’re going to do by grabbing your attention in such a forceful way that it can kind of manipulate you.

How has removing those attention-grabbing technologies changed your quality of life?

I have much more time. I think it makes a much more peaceful… I mean, it’s not such a big secret. The way to grab people’s attention is by exciting their emotions, either through things like fear and hatred and anger, or through things like greed and craving. If somebody [is] very afraid of immigrants and hates immigration, the algorithm will show him one story after the other about terrible things that immigrants are doing. Then somebody else maybe really, really doesn’t like President Trump, so they spend hours watching all kinds of things that make them very, very angry. And it doesn’t matter if it’s true or not—they see this headline of “President Trump Said the World is Flat,” they feel this irresistible urge to click on it.

It grabs your attention because you already have this weakness. But if you kind of sit there and just read infuriating stories for an entire hour you are basically feeding your mind with things that make you more angry and hateful. And this is especially bad if many of these stories are just not true. Sometimes they are true, quite often they’re not. But the net result is that you now just spent an hour feeding your hate and your fury.

It’s the same way with the other side of the coin, with greed. Because if you really want something—the perfect body, the perfect car—and you watch all these videos, you want it more and more. And if you don’t have it, then you feel worse and worse that you don’t have this kind of body, or you don’t have this kind of car. So you just spent one hour feeding your cravings and your greed, and it’s really not good for you.

The better you know yourself, the more protected you are from all these algorithms trying to manipulate you. If we go back to the example of the YouTube videos. If you know “I have this weakness, I tend to hate this group of people,” or “I have a bit obsession to the way my hair looks,” then you can be a little more protected from these kinds of manipulations. Like with alcoholics or smokers, the first step is to just recognize, “Yes, I have this bad habit and I need to be more careful about it.”

So how do you get your news?

I rarely follow the kind of day-to-day news cycle. I tend to read long books about subjects that interest me. So instead of reading 100 short stories about the Chinese economy, I prefer to take one long book about the Chinese economy and read it from cover-to-cover. So I miss a lot of things, but I’m not a politician and I’m not a journalist, so I guess it’s okay I don’t follow every latest story.

So, ummm… yeah. I’m out.

It doesn’t feel as if I’ve really made a big decision or anything because I haven’t spent any significant time on FB in the last year anyway.

Also, to be clear, I haven’t deleted my account or anything. The few things I’ve uploaded in the past are all still there, and I’m sure my timeline is going to tick by just as it has in the past. I just won’t be paying any attention to it.

If you need me, you know where to find me. And it won’t be on FB. :)

Parsons Problem Lesson: quad_functions

Learning Programming is Hard

Many challenges face the new Computer Science learner. One of the most interesting times for students learning to program is that period after they’ve learned a new feature or programming strategy, but before they’ve had a chance to really master it. The syntax may still be unfamiliar, or the strategy is “the same, but different” as something that they’ve seen before.

A Parsons Puzzle

I first stumbled upon the “Parsons Problem” type of question in a paper by researchers Denny, Luxton-Reilly, and Simon, Evaluating a New Exam Question: Parsons Problems, published in 2008, which led me to Parsons and Haden’s original paper Parsons’ programming puzzles: a fun and effective learning tool for first programming courses.

A “Parson’s Puzzle” is a programming problem delivered via computer, in which code fragments, manipulated via a drag-and-drop interface, may be assembled to form a correct, working program. Clicking a “Check” button would provide some sort of feedback. Parsons and Haden proposed that the nature of the puzzle would improve engagement with the topic, provide better structure for students still struggling to understand fundamental logic, strategies, or algorithms, and even intentionally allow for common errors so that a student could get immediate feedback on fundamental misunderstandings.

Parsons and Haden’s original idea of helping to teach students with an automated system was adapted to a paper-based means of assessing students by Denny, Luxton-Reilly, and Simon. Along the same lines, it’s certainly possible to use a paper-based strategy of helping students develop and clarify their thinking on any given computer programming topic.

A Paper-Based Parsons Problem in the Classroom

In an introductory computer science course taught using Python, students had recently learned about functions, and had had the chance to learn how to use functions in several different contexts. Students were paired randomly and given a paper copy of the activity here [PDF], and asked to a) arrange the lines of code into strips of paper that they would assemble into a working version of the program, and then b) enter their code into the computer to verify that it works as intended.

This program solves quadratic equations using three functions:
* one function to get the coefficients a, b, and c
* one function to calculate the two roots, and
* one function to print out the results
@author You
@version 1.0

def get_coeffs():

def get_coeffs(a, b, c):

def calculate_roots(a,b,c):

def main():

def calculate_roots():

def display_solutions(root1, root2):

def display_solutions():


a, b, c = get_coeffs()

root1 = (-b + (b * b - 4 * a * c) ** (1/2)) / (2 * a)

root2 = (-b - (b * b - 4 * a * c) ** (1/2)) / (2 * a)

x, y, z = get_coeffs(a, b, c)

display_solutions(r1, r2)

return root1, root2


display_solutions(a, b, c)

print(root1, root2)

return a, b, c

print("The solutions are: ")

a = eval(input("Enter coefficient a: "))

b = eval(input("Enter coefficient b: "))

c = eval(input("Enter coefficient c: "))

r1, r2 = calculate_roots()

a, b, c = get_coeffs()

r1, r2 = calculate_roots(a, b, c)

if __name__ == "__main__":

#!/usr/bin/env python3


Students took the assignment seriously, and seemed to appreciate the nature of the puzzle, and the fact that all of the information was available to them—they just had to (literally) put the pieces together. There were some lively discussions—”Do we need a function header with parameters or not? Do we need the function to return a value or not?”—as well as a desire to get done with the puzzle-solving as quickly as possible in order to move onto entering the code into the computer to test their program.

For a larger assignment or project with many variations, the Parsons approach is not well-suited: there are too many variations that need to be considered. For students just learning to master a new topic, however—functions, conditionals, while-loops, for-loops, etc—the Parsons Problem strategy is a great way to build students’ skills and confidence in programming.


Paul Denny, Andrew Luxton-Reilly, and Beth Simon. 2008. Evaluating a new exam question: Parsons problems. In Proceedings of the Fourth international Workshop on Computing Education Research (ICER ’08). ACM, New York, NY, USA, 113-124.

Dale Parsons and Patricia Haden. 2006. Parson’s programming puzzles: a fun and effective learning tool for first programming courses. In Proceedings of the 8th Australasian Conference on Computing Education – Volume 52 (ACE ’06), Denise Tolhurst and Samuel Mann (Eds.), Vol. 52. Australian Computer Society, Inc., Darlinghurst, Australia, Australia, 157-163.

Demo: Encapsulation

The idea of encapsulation is fundamental to computers in a number of ways. Generally speaking, “encapsulation” refers to the idea of building a container around something, as if that thing were contained in a capsule. When it comes to computers, there are a couple of slightly different ways the term might be used.

Hiding code in a class, function, or library

Commonly in computer programming, encapsulation refers to the idea of hiding away the details of code. For example, you may write a bit of Python code that takes three coefficients for a quadratic equation a, b, and c, and calculates the real roots (solutions) of that equation:

a = 2
b = 4
c = -5
root1 = (-b + ((b * b) - (4 * a * c)) ** (1 / 2)) / (2 * a)
root2 = (-b - ((b * b) - (4 * a * c)) ** (1 / 2)) / (2 * a)

If you were having to write lots of programs to calculate quadratic roots, or if you wanted to be able to use those lines of code other places, you might very well write them into a small function or method called something like quadratic_solver that you could use in lots of different places. You might call that function like this:

roots = quadratic_solver(2, 4, -5)

In this single line of code, the messy details of multiplying, dividing, and square-rooting have all been hidden away from the main program. The details of that calculation have been “encapsulated” in the function.

Any time you import a library into your program–import java.util.Scanner; in Java, for example, or import random in Python–you are bringing in complicated bits of code that will be available for you to use without having to worry about some of the arcane, or mundane, or complex details that are contained in that code. The concept of encapsulation is extraordinarily powerful.

Programming languages: Machine code, Assembly, High-level

A second way of considering encapsulation is less obvious, but one that we use all the time.

High-level languages

You have almost certainly seen computer programs written in some “high-level” language like Python or Java. These languages are called high-level because they, for the most part, consists of syntax that might be recognized and understood.

Here’s a program that’s written in C, which adds up the numbers from 0 to 255 and prints out the result:

# include 

int main(void)
    int x, sum;
    sum = 0;
    x = 1;
    while (x < 256)
        printf("%d ",x);
        sum = sum + x;
        x = x + 1;
    printf("\nSum = %d\n", sum);

You may not understand everything in this program, but it certainly has a few English words in it, and even a programmer who doesn’t know C might be able to work their way through this program to identify how it works.

We have a serious problem, however. You may have heard that computers don’t understand English: they only work in binary digits, or “bits,” the zeroes and ones that are represented by a billion switches being turned “off” or “on.”

So how does the computer run this program?

It doesn’t. But there is another program on the computer–a compiler–that is able to take this program and convert it to something called Assembly Language.

Assembly Language

In Apple’s macOS, if you have the Developer Tools installed, you can use the gcc compiler in the Terminal to output a compiled version of the program.

$ gcc -o sum sum.c

What does this new version of the program look like? We can see the Assembly Language version by using the otool program:

$ otool -tv sum
(__TEXT,__text) section
0000000100000f10 pushq %rbp
0000000100000f11 movq %rsp, %rbp
0000000100000f14 subq $0x20, %rsp
0000000100000f18 movl $0x0, -0x4(%rbp)
0000000100000f1f movl $0x0, -0xc(%rbp)
0000000100000f26 movl $0x1, -0x8(%rbp)
0000000100000f2d cmpl $0x100, -0x8(%rbp)
0000000100000f34 jge 0x100000f65
0000000100000f3a leaq 0x65(%rip), %rdi
0000000100000f41 movl -0x8(%rbp), %esi
0000000100000f44 movb $0x0, %al
0000000100000f46 callq 0x100000f84
0000000100000f4b movl -0xc(%rbp), %esi
0000000100000f4e addl -0x8(%rbp), %esi
0000000100000f51 movl %esi, -0xc(%rbp)
0000000100000f54 movl -0x8(%rbp), %esi
0000000100000f57 addl $0x1, %esi
0000000100000f5a movl %esi, -0x8(%rbp)
0000000100000f5d movl %eax, -0x10(%rbp)
0000000100000f60 jmp 0x100000f2d
0000000100000f65 leaq 0x3e(%rip), %rdi
0000000100000f6c movl -0xc(%rbp), %esi
0000000100000f6f movb $0x0, %al
0000000100000f71 callq 0x100000f84
0000000100000f76 movl -0x4(%rbp), %esi
0000000100000f79 movl %eax, -0x14(%rbp)
0000000100000f7c movl %esi, %eax
0000000100000f7e addq $0x20, %rsp
0000000100000f82 popq %rbp
0000000100000f83 retq

This version of the program contains a series of commands–push, move, jump, add, call, pop, return–that manage the data in the program, addresses in memory (listed along the left side), and registers (like %esi). Some people program in assembly language, but you can see that it’s a much more complicated affair. The process of storing the value 1 in the variable x is, in assembly language

movl $0x1, -0x8(%rbp)

We can say that the assembly language instructions are “encapsulated,” or hidden away, so that we don’t have to worry about those implementation details. We can write our high-level code, and rest assured that the compilation process will take care of the dirty work for us.

Of course, we still haven’t gotten down to the 0s and 1s that the computer needs to run a program. Let’s go one step farther down.

Machine Language

In the process of compiling, we actually created a binary version of the program, with nothing but 0s and 1s. We can use the xxd program in the terminal to view that code:

$ xxd -b sum | cut -c 11-64
11001111 11111010 11101101 11111110 00000111 00000000
00000000 00000001 00000011 00000000 00000000 10000000
00000010 00000000 00000000 00000000 00001111 00000000
00000000 00000000 10110000 00000100 00000000 00000000
10000101 00000000 00100000 00000000 00000000 00000000
00000000 00000000 00011001 00000000 00000000 00000000
01001000 00000000 00000000 00000000 01011111 01011111
01010000 01000001 01000111 01000101 01011010 01000101
01010010 01001111 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000001 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00011001 00000000 00000000 00000000
11011000 00000001 00000000 00000000 01011111 01011111
01010100 01000101 01011000 01010100 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000
00000001 00000000 00000000 00000000 00000000 00010000
00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00010000 00000000 00000000
00000000 00000000 00000000 00000000 00000111 00000000
00000000 00000000 00000101 00000000 00000000 00000000
00000101 00000000 00000000 00000000 00000000 00000000
00000000 00000000 01011111 01011111 01110100 01100101
01111000 01110100 00000000 00000000 00000000 00000000

It is this code–these 1s and 0s–encapsulated several layers below our original version, that the computer uses to run the program.

These 0s and 1s are used to operate the digital hardware, the memory locations and the logic gates, that produce a given output. In fact, before we had keyboards, mice, and monitors, the personal computer was simply a set of switches with lights above them. Computer code was entered using the individual switches–a long, painful, error-prone process–and output was read from the computer as a series of flashing lights.

Here’s a programmer entering a program by hand onto such a machine. The resulting program displays (in binary, of course!) the prime numbers between 2 and 255.

Fortunately, we don’t have to enter binary logic instructions by hand. Those codes are encapsulated well beneath our high-level languages.

Demo: Binary Numbers

If you teach Computer Science, chances are that learning about the binary numbering system is part of the curriculum at some point.

Why teach binary?

Some people question whether or not binary numbers should be part of a high-level curriculum, given the multiple layers of abstraction between, say, a webpage and the binary code that brings that page to life. I’d suggest that:

  1. Those multiple layers of abstraction / encapsulation are very much a part of computer science, and a perfect jumping off point for a conversation about binary numbers.
  2. Students should understand that binary numbers are at the heart of every computer. A great video for demonstrating how people used to have to program computers is this one, demonstrating the programming of an old 8080 microcomputer. Follow that up with a demo of high-level / assembly / binary version of a program, described here.
  3. Learning how to decipher a binary number is not that difficult, and provides students with a manageable gateway activity to the field of computer science.

Demonstration strategies

Binary numbers can certainly be displayed on a computer monitor or projected in front of the class. An interactive Python session works just fine:

>>> bin(13)
>>> print(bin(13))

A more visible and physical demonstration of binary numbers can easily be constructed using an outlet power strip, socket adapters, and low-wattage aquarium light bulbs (see parts list below).

This device can be easily manipulated at the front of the room, with individual bulbs easily turned on or off simply by screwing them in tightly (on), or unscrewing them slightly (off). Students can be asked to identify the decimal equivalent of a binary number, or asked to manipulate the bulbs themselves to produce the binary equivalent of a decimal number.


This inexpensive and physical, practical demonstration device can be used in the classroom, with parents, during open house events, etc. It has become a mainstay of every CS course I teach.

Parts List