"a large portion of the uploaded code is copyrighted by the University of Illinois." seems to suggest the homework involved working on an existing codebase.
305 karma · joined May 31, 2012
It's also a deterministic (but difficult to reverse, I assume) algorithm, so it doesn't ever store anything, you just regenerate the password to "look it up".
With regards to the "crappy scoping", I can only assume he didn't read up properly, especially since both the globals and locals mentioned right after do exist.