Department of Mathematics, Computer Science, and
                Statistics
St.
                Lawrence University
Zonohedron
 

What is this object?

...

Links
Overview
Schedule
Grading Info
Class Notes

 

CS 140: Introduction to Computer Programming


HOMEWORK #8
due Friday, Nov 9 by 5:00pm

Guidelines for completing and submitting homework
Refer to the first two paragraphs on the Grading Info page for all the details.  Briefly, you may not collaborate with your classmates while writing homework programs.  However, you may certainly consult Spencer on Thursday evenings or Dr. V on Friday afternoons as you create your programs.  (Email your program to me first to check that I'm in the office.)  Other QRC mentors may also be able to help out, depending on their experience with Python.  Once you have completed your program, or made as much progress as possible, email your program as an attachment to svandervelde@stlawu.edu.

Assignment
To begin, create a new document in Komodo and include these comments at the top
# Your full name
# Homework #8, Nov 9, 2012
# Individuals providing assistance, if any

Then save your file using the format LastnameHW8.py.

This week you will complete the database.py program we began in class, as detailed below.  (You can find a copy on the schedule if you missed class.)  I would recommend working on that file, saving as you go, until it is complete.  Then save a copy in the format LastnameHW8.py as usual to submit.
  • Define a function printrows(records) that takes our array as input and prints out the data as a series of numbered rows, beginning with row 1.  (Don't worry about tabs for this printout.)  So the first row should look like
    1) Ben Austin, class 2016, color blue, fav number 25.

  • Define a function addrec(records) that takes our array as input and prompts the user for a first name, last name, class year, favorite color, and favorite number.  It should then append a new row with this data to our array and return the new array.

  • Define a function deleterec(records) that takes our array as input and first displays all the records (using the printrows function), then asks the user to enter the row number of the record they wish to delete.  The function should then delete this record and return the new (shorter) array.  Remember that the row number is not quite the same as the position of the record within our array.