Ramblings of a math and CS teacher

March 23, 2005

Teaching Introductory Computer Science with Python

Filed under: Uncategorized — danschellenberg @ 4:30 pm

Why Teach With Python?

Python is a great object oriented computer language that is very useful in introducing students to computer science. One of the major highlights of Python is the fact that it teaches proper coding technique and concepts, but is much easier to learn than some other, lower level, languages such as C++. C++ is a great language, but in introductory computer science classes using C++, much time must be spent teaching the conventions of C++ before true programming concepts can be addressed. This can be illustrated by comparing the traditional “Hello World” program in C++ and Python:

C++ Hello World Program

#include <iostream.h>
void main()
{
    cout << "Hello, world." <<
}

Python Hello World Program

print "Hello, World!"

This example is cited from Jeffrey Elkner’s essay on why he chose to shift from teaching computer science using C++ to teaching with Python. If you would like to read a more indepth explanation of the merits of using Python to teach computer science, see his essay. Elkner is a teacher in Arlington, Virginia, and has had great success in teaching computer science with Python. In fact, Mr. Elkner has translated the textbook How To Think Like a Computer Scientist, originally written for Java, into a textbook to teach CS concepts using Python (this text is freely available, as it is licenced under the GNU General Public Licence, though you can also order it from Amazon if you like). This is a great, free resource that in itself is a compelling reason to consider using Python as the language of choice when teaching computer science. You can print out copies of the text, or simply have your students read it online.

Python is much more than a learning language, though. It is used in many modern applications, from the popular Google web search to a vast array of desktop applications (Python is available on Windows, Mac and *NIX). However, I will leave the task of convincing you that Python is a great language to others, and move on to describing how which resources to use in an introductory computer science course (CS 20 here in Saskatchewan) based on Python.

Computer Science Course Resources

  • Guido van Robot
    • Guido van Robot is a great unit to begin the semester with. The GvR language consists of 5 basic commands (see the command reference), and provides graphical feedback to the new programmer as (s)he works with the code. Interestingly, GvR was created by Jeffrey Elkner’s computer science class (using Python).
    • There are 18 tutorials/mini-lab lessons that you can have your students complete to learn and explore the GvR language, which encapsulates a number of important CS concepts.
    • I would recommend using GvR for the first couple of weeks of your CS20 class.
  • How to Think Like a Computer Scientist: Learning with Python textbook
    • free textbook available for reading online or printing out
    • explains the basics of computer science in a very reader friendly way, while using Python examples to illustrate the points
    • within the text are exercises that are very good in the classroom to confirm students understanding. These could be either hand-in assignments, or simply in class exercises, at the discretion of the instructor.
    • does not assume that an IDE is being used while learning Python, which I believe to be a very good thing. There is no need for the students to worry about learning an IDE while also learning the basics of CS — learning about IDE’s could occur in a second course in CS (CS30). There are many Python IDEs, though one of the best is SPE (also see a tutorial on SPE).
    • although I do not believe that an IDE is necessary in an introductory CS course, there is something to be said for syntax highlighting in your text editor. To this end, I would recommend having TextWrangler or SubEthaEdit available on your Mac OS X machines (both are freeware and Python syntax aware, along with a many other languages). On Windows machines, PSPad is a very good text editor.
  • CS Practise Problems Archive
    • a listing of practise problems that have been used in CS classes while teaching with Python. If you develop your own, submit them and help the archive grow!
  • Modules useful for practise problems/fun examples
    • a good module to use if you want to have your students retrieve current international weather information for use in their programs is PyMETAR. Makes utilizing current weather information quite simple.
    • Fraction.py is a “fairly robust fraction class” that can come in really handy when dealing with fractional representations of numbers.
    • PyBlogger is a Python wrapper for the Blogger and MovableType APIs (as of this writing)
    • PyGoogle is a wrapper for the Google Web APIs. It allows you to do Google searches, retrieve pages from the Google cache, and ask Google for spelling suggestions.
    • PyAmazon is a wrapper for the Amazon web API. Allows you to do Amazon searches by keyword, ASIN, UPC, author, artist, actor, director, manufacturer, list, similar, or best seller.
    • IMDbPy is a Python package useful to retrieve and manage the data of the IMDb movie database about both movies and people.
    • whois.py contacts the NetworkSolutions/Register.com whois database for each domain and displays the result.
    • googlism.py module provides both Python module and command line access to googlism.com, the Web site which sifts through the results of the popular search engine Google and reports information about individual keywords.
    • GeoIP Python API identifies the country of a certain IP address.
    • dict.py is a module that speaks the DICT protocol used by dictionary servers.
  • Various Useful Python Sites

March 21, 2005

Linux in Education Experiences/Suggestions

Filed under: Uncategorized — danschellenberg @ 3:28 pm

Over the past few months, I have taken some time to play around with a variety of Linux distributions in the hopes of increasing my ability to utilize Linux in an educational setting. Instead of attempting to determine what distribution of Linux would be suitable for a computer lab setting (see the K12LTSP project for info on setting up easily maintained Linux labs), I have instead focused on which distros are suitable for deployment in the context of single classroom workstations. From my experience in classrooms, chances are quite high that if you manage to obtain workstations in your classroom, they will usually consist of outdated hardware that is no longer seen as suitable for lab use. For this reason (in addition to my lack of quality resources!), I have done my testing primarily on legacy hardware similar to what one might encounter in the classroom.

Because of the limited hardware resources that I anticipate having on classroom workstations, the primary purpose of these machines will be non-media intensive. We will leave off on editing audio and video and such for machines better equipped for the task. The essential tasks for these machines, as I see it, is to allow for web browsing and word processing. Having a spreadsheet application would also be nice, especially as a math teacher, but is not essential in most classrooms. For machines with a bit more processing power, the KDE Edutainment Project would also be useful, but is not essential.

In order to compare the various strengths and weaknesses of the distributions I tried, I have created a table listing my findings. For those looking for a more comprehensive overview of various linux distributions, check out the distrowatch.com site.

To summarize what I have found, I would recommend installing VectorLinux on older machines destined for the garbage heap. If there is a larger hard drive in the machine, installing VectorLinux SOHO is a good idea, even if you have to change the window manager from the default KDE to IceWM (the window manager is a major factor in the speed of the system, and on older hardware, using IceWM or XFCE is much better than attempting to use KDE or Gnome). VL SOHO gives you a good set of packages, so in most circumstances you will not need to install any additional packages. If the hardware is quite old, I would recommend using AbiWord instead of OpenOffice for word processing; AbiWord is much more responsive than OpenOffice on older systems.

For a workstation that has newer hardware, I would recommend installing SimplyMEPIS Linux. This is a very nice looking system that comes with virtually all required functionality out of the box, and has a great package manger should you need to add additional software.

Of course, these are simply my recommendations, and each user has their own preferences to accomodate. Enjoy exploring linux!

March 16, 2005

Case-insensitive File Completion With the bash Shell

Filed under: Uncategorized — danschellenberg @ 1:28 pm

If you spend much time in the terminal on OS X (or any *NIX based system, really), you might find the following tip useful (via Borkware.com):

If you use bash as your shell and use filename completion a lot, you can get bash to ignore the case of filenames just like HFS does. Just put this in your ~/.inputrc file:

set completion-ignore-case On

Then when you type ls /appli in the shell you’ll get ls /Applications/ like you ought to!

Note that filename completion is invoked by simply hitting the tab key when specifying a directory name. This can come in really handy when typing a long directory name, or a directory name that includes spaces.

March 15, 2005

Add a Virtual PDF Printer to Mac OS X (or How to Save Copies of Completed PDF Forms from Acrobat Reader)

Filed under: Uncategorized — danschellenberg @ 7:55 pm

The form that started this whole adventure for me was from Snort.org (a network intrusion protection site), with the form in question being a scholarship application (or view the local copy of this pdf). When you open this form with Adobe Reader (sorry, Preview doesn’t work for this!), you will find that the data fields on the second page act in the same way as an HTML form; you can type directly into these fields, thus theoretically avoiding the need to print the form onto paper. Now, after filling out a form such as this one, it would be really nice to save a local copy onto your hard drive instead of having to print a paper copy. Normally, this would be accomplished on Mac OS X by simply saving a .pdf file of your current document by clicking on the “Save as PDF…” button in the Print dialogue. Unfortunately, Adobe has disabled the “Save as PDF…” button in their Reader application, which caused me some annoyance.

This is one of the situations where a dedicated PDF Printer comes in handy: if for some reason you can’t use the “Save as PDF…” button, you can simply “Print” directly to a PDF file, accomplishing the same goal through a different method. (Note that another use of this dedicated PDF printer could be to allow networked Windows machines to use it to have hassle free printing to PDF)

I wanted an easy, free method of saving PDF forms I have filled out onto my computer. While I could fork out $299 USD to get a copy of Adobe Acrobat 7.0 Standard Edition, there are very few things that I need it to do that Preview or Adobe Reader cannot (save forms, encrypt pdf’s). The other option would be to pay $44.33 USD for the shareware PDF-FormServer application. I should note here that PDF-FormServer does provide added functionality over my free solution, namely in that it allows you to go back and edit the form data at a later date, whereas my solution keeps only a non-editable copy of the form. I have found this unnecessary for my needs, as Acrobat Reader is able to accurately guess the information that I enter into forms (mainly my address, etc.), so it takes very little time to go back and re-enter information into a form. Your mileage may vary…

As alluded to above, the method that I hit upon was creating a “virtual printer”, whose only function was to output a PDF file of whatever I was working on. After a bit of research, I found out how to do this from a discussion on the macosxhints.com website. I will copy out the required steps (and supplement them a bit) to follow to create a virtual PDF printer on Mac OS X (tested on 10.3 — 10.2 not supported). These steps assume you do NOT have Acrobat Distiller PPD installed; check the discussion listed above for details on how to do this if you do.

  1. Open the terminal (found in /Applications/Utilities by default). Don’t worry if you aren’t used to working in the terminal — I’ll give very precise instructions.
  2. Type in the following commands, in this order:
    1. cd /usr/libexec/cups/backend and hit Enter.
    2. sudo pico pdf and hit Enter (This will open up a Unix text editor called pico. You will be asked to enter your administrator password. If you have only one account, it should just be your regular password. The reason you to enter a password is because you are adding a file that is going to live in a directory that your user doesn’t “own”, because it is a system-ish folder.)
    3. Copy and paste the entire contents of this text file into the terminal window.
    4. Hold down the control key, and press x. (ctrl-x)
    5. Press y.
    6. Press Enter.
    7. sudo chmod a+x /usr/libexec/cups/backend/pdf and hit Enter. If you are prompted for your password, enter it in again.
    8. sudo killall -HUP cupsd and hit Enter.
  3. Open the Printer Setup Utility application (found in /Applications/Utilities/ by default).
  4. Hold down Option and click on the Add button. In the top list, select Advanced. For Device: choose PDF Writing. Give it a descriptive name (e.g., PDF Writer). For the device URI, use pdf://pathname, where pathname is where you would like the PDF file to be saved — I set mine to PDF://~/Desktop so that it saves the file onto my desktop. Leave the printer model as Generic. Click on Add, and it is all ready to go!

I found that the first time I used the virtual PDF printer, it took a bit longer than normal to generate the .pdf file, but after using it a few times, it either sped up or I stopped noticing.

If you would like to see the results of this printer, check out this copy of the semi-completed pdf form that I printed from Adobe Reader.

March 9, 2005

Mac OS X Fast User Switching Suggestions

Filed under: Uncategorized — danschellenberg @ 2:34 am

Although I don’t use multiple users under OS X very often, there are occasions where I do find the functionality very useful. In particular, having an extra user set up for the express purpose of being the “presenter user” has saved me some time over the long run. After setting the system preferences for the user once, I know that things will be as I want them when I use the account for a presentation/demo. All that remains is to put whatever file(s) I need into the Shared user directory, and I am ready to present on a pre-setup account.

Note: The only relevant system preference that cannot be set on a per-user basis (that I have found, anyhow) is the Energy Saver settings. This makes sense, as you don’t want some other user setting the computer to fall asleep when your user says it should never sleep. This setting is an important one to remember to check, as you don’t want your Mac falling asleep in the middle of a slide. For those who are geek-minded and want to do some Very Cool Things, the preference file for your energy saver settings lives at:

/Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist

You may also be interested to hear that there is a shell command (pmset) that can be used to alter your settings from the command line (such as in a login item shell script as demonstrated on the Managing Mac OS Blog).

Putting the finer points of customizing your user account behind, we are left with the problem of just how to switch to this shiny new account without completely interrupting your regular workflow. Apple’s built in implementation of Fast User Switching, while functional, leaves a fair bit to be desired. Menu bar real estate is hard to come by, and having your full name printed out in the menu bar is not exactly sound use of available space:

Image of Apple's Fast User Switching Implementation

A better option is to use WinSwitch, a handy open-source application that lets you customize the appearance of your menubar username. You can stick with the classic full name, use initials, just the first name, icons, etc. This allows you to have the same functionality as the Apple implementation with a little less space requirements:

Image of WinSwitch's Fast User Switching Implementation

And now, the best option — powered by the wonderful utility, Quicksilver. Using the Quicksilver method, there are no menubar items whatsoever, so there is no wasted screen space involved with the fast user switching action. If you don’t already use Quicksilver, go do yourself a favour by downloading it and checking out a beginner’s tutorial. Done already? Great. Now, install the User Accounts Module from the Quicksilver plugins page. All you have left to do is to activate Quicksilver and start typing in the name of the user account you would like to switch to. It should look like this:

Image of Quicksilver's Fast User Switching Implementation

Enjoy your newfound ability to switch users on the fly, without having to waste tons of space in the menubar!

March 7, 2005

Upcoming Fix for Pesky Pop-under Ads

Filed under: Uncategorized — danschellenberg @ 5:16 pm

In the past few weeks, some pop-up ads have apparently begun to bother even those using browsers that profess to be invulnerable to such exploits (Safari, Firefox, Opera…). While I have not experienced this problem myself, I can completely understand why people are extremely annoyed with it. I have spent the past 2 years or so using Safari as my primary browser, and have seen no popups in that time. I can’t imagine what would possess people to put up with a browser that allows popups to occur.

In addition to using Safari to block popups, I also use PithHelmet to block unwanted banner ads, irritating GIF animations, etc. I have become so accustomed to not seeing ads while browsing that it always surprises me when I am using a PC in a lab and there are suddenly ads littering the content I am familiar with.

For fellow users of Safari and PithHelmet who have experienced pop-up/pop-under ads sneaking through the defenses lately — keep your eyes peeled for a new version of PithHelmet to protect against such annoyances. PithHelmet developer Mike Solomon has written in his development blog that he has the functionality coded, and is just in the process of adding it to the stable version of PithHelmet. Ahhh — no need to fear the evil popups…

March 1, 2005

Appcasting Ideas

Filed under: Uncategorized — danschellenberg @ 3:47 pm

Appcasting is defined as:

Appcasting is the practice of using the ‘enclosure’ feature of RSS 2.0 feeds to deliver updates and release notes for new software applications. The name Appcasting is by analogy with Podcasting, which is the practice of delivering audio files as RSS 2.0 enclosures.

The idea is this: the developer publishes an RSS 2.0 feed, each item of which describes a new release of a particular software product. The items’ descriptions may contain release notes or other information about what’s new in this release.

Although Appcasting has been around for awhile now, I have yet to find a feed that I would be willing to subscribe to. That said, there is undoubtedly a lot of potential in the idea of appcasting, which has been most notably used in podcasting so far. The general form of appcasting could go so much further than simple podcasts, though.

A number of nifty ideas come from a post by Will R., who suggests a number of uses of appcasting in education. One idea that popped into my mind was the distribution of important information from the office to teacher classroom computers. For example, if the school creates a daily teacher update document (as the school where I spent my internship did), it would be quite simple to teach the secretary to publish this file as a RSS enclosure. This would allow each teachers computer to download the daily update (or whatever else the school wanted to distribute) in the background, without the teacher having to remember to do anything.

Blog at WordPress.com.