Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Perl Assignments Needed

by exodist (Monk)
on Sep 18, 2007 at 17:17 UTC ( [id://639698]=perlquestion: print w/replies, xml ) Need Help??

exodist has asked for the wisdom of the Perl Monks concerning the following question:

I work at a Charter highschool teaching computer science. I have 2 advanced student to whom I am teaching the perl programming language. The students are picking it up at a good pace, however I am absolutely stumped when it comes to giving them assignments. Sometimes the assignments are trivial and take only a few minutes, other times ones I think are simple are far beyond their capabilities at this point.

So what I am looking for are some good ideas for assignments ranging from very easy to slightly more difficult.

So far I have taught them basic syntax, looping structures, conditionals, some basic regexp stuff, keyboard input, output to screen, and some basic file IO.

--------------------------------------

I would rather take 30 minutes to re-invent the wheel then take 30 days to learn how to use someone else's. Before pestering me about my re-invention prepare to defend yourself with a way of learning how to use the wheel in less time than it takes for me to make one, one that I might add is specialized to my specific task!

Replies are listed 'Best First'.
Re: Perl Assignments Needed
by eff_i_g (Curate) on Sep 18, 2007 at 17:44 UTC
    How about:
    • Mimicking some Unix command line utilities (and possibly adding improvements).
    • Having them parse logs (Apache, etc.) based on your requirements.
    • Giving them simple examples, but requiring that they use a module or modules from CPAN (in order to etch that into their habits).
    • Having them convert/write a simple script in OOP and write POD for it.
Re: Perl Assignments Needed
by samtregar (Abbot) on Sep 18, 2007 at 17:27 UTC
    Why not have them program some games? Start with something simple like a dice game or a reflex tester. If they dispense with that easily maybe show them a little Tk or SDL so they can add graphics. Or perhaps do it with CGI and HTML, which might be a little easier to learn and ultimately more useful.

    I spent a very enjoyable year in junior-high programming a hilarious choose-your-own-adventure in BASIC on an Apple/II. Armed only with PRINT, IF, GOTO and READ I had a blast. Just imagine what I could have done with a teacher!

    -sam

      Ah, now that brings back memories... In my case, I taught the school's Apple ][s to play a 'lost in the desert' text adventure in the Zork style... Thanks for reminding me.
Re: Perl Assignments Needed
by dwm042 (Priest) on Sep 18, 2007 at 18:04 UTC
    You might consider a real world project, whose assignments would be stages in the project. One idea might be a web page for the high school football team, with scores and stats. Assignment might be things like:

    • Introduction to MySQL
    • MySQL I/O using Perl DBI.
    • Calculations using data read from MySQL database.
    • Introduction to Perl CGI.
    • Making a dynamic web page.
    • Making an input form.
    The example I give would require access to a MySQL database and an apache server. But setting those up could be an assignment too ;).

    If your local football coach can't give you data, then one assignment could be:

    Scraping high school football data off the local sports page.
      Then again, if these students' feelings about the football team are anything like mine were when I was in high school, this project might end up with a few not-exactly-benevolent "quirks" or "easter eggs" in it...

      Great concept, just make sure that the students are favorably-disposed towards the subject matter.

Re: Perl Assignments Needed
by perlofwisdom (Pilgrim) on Sep 18, 2007 at 21:13 UTC
    Kids are very into their music, yet downloaded music files are often not well organized. There are a number of perl modules that can read the headers of an mp3 file (ie., Artist, Title, Album, etc). So, have your students create a program that:

    A) sorts the music files on their pc,

    B) creates directories (they decide how to organize the directory names),

    C) move the files to the appropriate directory,

    D) Clean up (remove) any empty directories,

    E) Print summary reports of content, i.e. number of songs in each category: by artist, by genre, artist unknown, etc.

    F) Extra Credit for any other bells and whistles.

    You can use this project to satisfy multiple learning objectives. They can go to CPAN and do a search on mp3 to get a variety of modules they can use. The larger program can be built in smaller increments as they learn to search for directories, download modules, read documentation, etc.

    Good luck!!!

      part C) is extremely tricky as i have tried many different methods and im not getting the expected output or errors

      Does anyone have code for this

        Does anyone have code for this

        No, you're supposed to write it

Re: Perl Assignments Needed
by Anonymous Monk on Sep 18, 2007 at 17:56 UTC

    More possibilities:

    • A program to get some basic statistics (mean, standard deviation, median, etc) from a list of numbers
    • A program to generate a concordance from a given text.
    • Hangman or a similar word game.
    • A program to solve, using the Newton-Raphson method, polynomials.
    • Any of the lower level problems in Knuth's Art of Computer Programming

    emc

    Information about American English usage here and here.

    Any Northeastern US area jobs? I'm currently unemployed.

Re: Perl Assignments Needed
by amarquis (Curate) on Sep 18, 2007 at 18:34 UTC

    How much math is in your computer science? I remember in my high school the assignments were mostly simple computational physics and math problems.

    If you are interested in computational stuff, you might want to check out Project Euler. They have many, many problems, some of which are suited to a novice programmer (Problems like "How many numbers from 1 to 1000 are divisible by 3 or 5?"). They are all problems that can be solved in a multitude of different ways, and the first ones can be done with a few lines of efficient Perl.

    Also, I don't know your students, but would it be fun to have a golf or speed competition? Let the kids see who can make the shortest or fastest solution, and then discuss it? Just tossing out ideas.

    (I'll admit, I laughed at the anonymous monk's easy assignment)

      How much math is in your computer science? I remember in my high school the assignments were mostly simple computational physics and math problems.

      When I was at high school, I liked very much to mix my programming skills with the knowledge I got from other subjects. For instance:

      • write a 2D solar system simulator
      • reproduce Mendel experiments
      • write a plotting program for math functions
      • write a linear equation solver
      • draw 2D proyections of simple 3D figures
      • ...

        The 2D solar system simulator is kind of neat, I remember doing that too.

        The reason that I lean towards some sort of math problem or physical simulation is that when I was in high school I was always wondering "Where's the application of this? How good do I have to be before I can do anything with direct application?" in my programming classes. With something like a 2D solar system simulator you can say "Hey, I built something that charts the courses of the planets based only on the laws of physics and my programming skills, how neat is that?"

Re: Perl Assignments Needed
by mmmmtmmmm (Monk) on Sep 19, 2007 at 01:51 UTC
    I'm surprised nobody has mentioned Learning Perl. Full of great exercises. The exercises are not overly simple, but should take less than an hour to complete. Perfect intro to the language, and programming in general. It's also written in a more relaxed style that will be less intimidating to a high school student than something like Knuth.

    Once you feel like they've got the basics down, maybe check out Intermediate Perl (which also has great exercises). It is hard sometimes as a novice programmer to see how all of those basic skills can be put together to make something interesting besides just adding numbers and printing the result. This book bridges the gap well.

    Also, given the amount of time that kids spend on the internet nowadays, I'd recommend showing them some of the stuff out of a book like Spidering Hacks, or Perl & LWP. This might stimulate their interest, and is something they can actually use in their day-to-day lives. Maybe have them write a program automatically check for any new posts on a few of their friends blogs/myspace pages/livejournals/etc.

    I think these types of exercises work much better than abstract simple exercises such as "Write a program for the factorial of a number...",etc. These sort of exercises bore the hell out of a kid, who'd rather be blasting aliens in Halo 7 than writing trivial scripts for math problems on a computer. Try to find something that they can relate to, and apply to make something they enjoy easier.

    Maybe give them an open assignment, like "Take a task you do everyday on the internet, and automate it using Perl." Kids have very creative minds, and I wouldn't be surprised if some of your students came up with something that hasn't been thought up yet.

    ---mmmmtmmmm
      "Take a task you do everyday on the internet, and automate it using Perl."
      Such as:
      • A podcast downloader (XSS feed reader).
      • A synchronizer for hotpluggable devices.
      • A downloader that pulls videos off your favorite web site.
      --
      Andreas
Re: Perl Assignments Needed
by snopal (Pilgrim) on Sep 18, 2007 at 18:36 UTC

    One of the most important lessons for Perl programming is SCOPE! There are a lot of things that teach scope; from simple block variable management, loops, the differences between 'my' and 'local' and 'our', all the way up to closures.

    By providing an introduction and expansion on this subject alone, you will provide them with a very powerful understanding of an essential feature within object-oriented (and structural) programming that they can carry with them for the rest of their career.

Re: Perl Assignments Needed
by planetscape (Chancellor) on Sep 19, 2007 at 01:09 UTC
Re: Perl Assignments Needed
by Anonymous Monk on Sep 18, 2007 at 17:49 UTC
    go through the current Seekers of Perl Wisdom listings, and then go back through the archives.

    maybe only one in twenty or thirty questions posted therein will be appropriate for your students, but that's still a lot of stuff.

      another nice feature of perlmonks questions is that they come with answers. these answers often show a variety of approaches, some (much) better than others, and sometimes include just plain bad answers. lots of opportunity to compare and contrast, and in my experience bad answers -- if they are flagged as such, and pm discussions will usually do this -- are sometimes as enlightening as good ones.
Re: Perl Assignments Needed
by scorpio17 (Canon) on Sep 18, 2007 at 18:46 UTC
    Take a look at Perl Cookbook, from O'Reilly. It's full of interesting case studies - most all recipes are relevant to real world problems, and most offer several possible solutions, of varying complexity.
      I will echo the Perl Cookbook suggestion.

      That book along with an experienced mentor was more than enough to get me started on my way to years of ego-building, um, er, perl programming.

Re: Perl Assignments Needed
by pemungkah (Priest) on Sep 18, 2007 at 20:11 UTC
    Okay, so at this point they can do fairly simple programs. The question is "what direction is best at this point?" I would recommend teaching them how to get programs written, rather than fiddly numbers problems - they may need a few of those to feel comfortable, but getting the real tools into their hands: modules, and thinking like a programmer - this is what will be most valuable to them.

    If you want to concentrate on programming per se - as in, learning how computer sciency stuff works - I might recommend working through the examples in Kernighan and Plauger's "Software Tools". It's amazing how much meat there still is in that book. You'll need to work with them to recast the problems into Perl - and that may be a very valuable experience for them. Certainly it was for me.

    The Cookbook is a great way to move through the spectrum of Perl programming as well, as previously mentioned.

    Two things I would emphasize if I were teaching a beginning programming class again would be how to write tests (Test::More and the like) and how to use the debugger. You may want to spend a little time on modules and how they work; you can then show them how CPAN can vastly help them in getting stuff done, possible bringing in Module::Starter.

Re: Perl Assignments Needed
by johngg (Canon) on Sep 18, 2007 at 22:23 UTC
    You might be interested in some of the ideas put forward in this thread from a few months ago.

    Cheers,

    JohnGG

Re: Perl Assignments Needed
by bwelch (Curate) on Sep 18, 2007 at 18:40 UTC
    Try to find assignments that are both interesting and fun. Games work well for this, even if they are simple. If possible, make it so students can compete with each other. Better yet, let the student's programs compete with each other.

    Another approach could have students create things that are useful to them. Assignments that are useful for other classes or at home would (hopefully) allow students to see the value of using Perl. This is probably harder to create and only reasonable if you see something appropriate.
      The classic for 'program vs. program' is robot programming. This can be aibots (Perl engine, proprietary robot command language) or http://realtimebattle.sourceforge.net/ (Unix, message based communication via pipes, agnostic to programming languages).

      A fun way to introduce and evolutionize concepts: E. g. students will develop a maze of 'if' statements; you introduce state machines.

      Becoming off-topic I'd not teach the language but problem solving, common algorithms and concepts. Perl has a lot of algorithm per line of code, reducing distraction.
Re: Perl Assignments Needed
by Cap'n Steve (Friar) on Sep 19, 2007 at 05:51 UTC
    I thought we frowned on homework questions here. ;)
Re: Perl Assignments Needed
by Aim9b (Monk) on Sep 18, 2007 at 18:24 UTC
    I don't feel qualified to offer any assignment examples, as I'm a newbie myself. However, the SoPW here at the monestary should be required reading. I'ts been "my teacher" for the past 8 weeks or so, and doing an outstanding job. I would also recommend Damian Conway's Perl: Best Practices.
Re: Perl Assignments Needed
by toma (Vicar) on Sep 19, 2007 at 16:25 UTC
    A program to generate a scene in POV-Ray makes a great assignment. I assigned a castle. A sub makes a brick, another sub makes a wall, etc. Use a little trig to make a turret. You could also say that the brick should look like a Lego. The students can build what they draw if they want.

    This assignment generates an artifact that doesn't require a computer to see it. You can print it out, and it actually looks like something.

    It should work perfectly the first time! - toma
Re: Perl Assignments Needed
by brian_d_foy (Abbot) on Sep 21, 2007 at 16:07 UTC

    I wrote the Learning Perl Student Workbook as a companion book of additional exercises for Learning Perl. It's 64 pages of exercises and answers, and many answers provide multiple solutions to the same problem.

    Good luck!

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
Re: Perl Assignments Needed
by Anonymous Monk on Sep 20, 2007 at 11:56 UTC
    When I was in high school, we did various projects including:

    - a pizza shop's register software. It doesn't have to be complex, but it will demonstrate how they can build a menu system and compute some simple costs for toppings and delivery costs.

    - compute some mathematical formulas: like American to metric conversions, area, volume for various shapes. It should use a menu system so that users can select the type of computation and be prompted for inputs.

    j

Re: Perl Assignments Needed
by girarde (Hermit) on Sep 20, 2007 at 19:39 UTC
    In PerlMonks Jeopardy, the answer must be phrased as a question.
Re: Perl Assignments Needed
by Anonymous Monk on Sep 18, 2007 at 17:19 UTC
    Very easy assignment: $a = 1;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://639698]
Approved by ikegami
Front-paged by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-16 19:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found