CPSC 217: Mini-Assignment 4b

Due at 4 PM. For assignment due dates see the main schedule on the course webpage. The program must be written and run under python version 3.X.

New Concepts to be applied for the assignment

Functional requirements

In order to get credit for this assignment you must use the starting code ("map_starting.py"). The starting code will randomly populate a 4x4 list and display the current state. Because the initialization is random you will get a different pattern each time that you run the program so your program must work regardless of the starting pattern.

Here is an outline of the entire program:

def clean(world,endRow,endColumn):
   # You must implement
(it's largely empty)
 

def count(world,endRow,endColumn):
   # You must augment

# Randomly generates an 'occupant' for a location in the world
def createElement():
   # 
It's been pre-written for you :D

# Creates the SIZExSIZE world (SIZE = a named constant). Randomly populates it with the
# return values from function createElement
def createWorld():
   # 
It's been pre-written for you :D

def getEndPoint():
   # You must implement

# Shows the elements of the world. All the elements in a row will appear on the same line.
def display(world):
   # 
It's been pre-written for you :D

def start():
    world = createWorld()    # Randomly generate world using the above two functions: createWorld and createElement
    display(world)

    endRow,endColumn = getEndPoint() # Get the last (row,column) on which the clean and count operations will affect
    element,number = count(world)    # Count # instances (in the world) of a user entered character

    print("# occurances of %s=%d" %(element,number))
    clean(world)   # Remove the "undesired bio-matter debris" from the world
    display(world)    # Show again the 'cleaned' world

start()

Below is the additional details of the three functions you are to implement for this assignment: count(), clean() and getEndPoint():

def count(world,endRow,endColumn):
    print("Counting number of occurances of a character")
    number = 0
    element = input("Enter character: ")
    # Insert your answer here for counting occurances
    return(element,number)

(Worth 1.0 GPA) Description of getEndPoint():

  • Input/parameter/argument: None
  • Return value: two integers.
  • The function will repeatedly prompt the user for the 'end point' (last row and column) on which the count and the clean operations will occur. For instance if the user enters a row of 3 and a column of 3 then the two operations will occur from row 0 to row 3 and from column 0 to column 3 (i.e. the whole list). If the user enters a row of 0 and a column of 0 then count and cleaning will only occur on the first element. The program should indicate to the user the valid range of values that can be entered (0-3) and repeatedly prompt for a value so long as a value outside this range is entered. That is this function must return two numbers in the range from 0 - 3. It can be assumed that the user will only enter an integer value.

(Worth 1.5 GPA) Description of Count():

def clean(world,endRow,endColumn):
    print("Scooping the poop")

    # Insert your answer here for removing instances of the 'poop' character - another pre-defined named constant

(Worth 1.5 GPA) Description of Clean():

  • Input/parameter/argument: a reference to a 2D list (already randomly initialized), the last (row,column) on which the cleaning will occur.
  • Return value: None
  • The function will find and replace all occurances of the 'poop' character (POOP = "O") with the 'cleaned' character (CLEANED = ".")
  • Note: that in the start() function after returning from clean() the 'world' list will be displayed again so the user can see the updated world.

Note: you can be awarded credit for each of the 3 functions regardless of whether the other functions were complete or correct. For instance you can be awarded 1.0 GPA for just writing a function that properly gets the end point from the user. Conversely if your function for getting the end point wasn't correct but the other functions were complete and correct (i.e. the count and cleaning always occurred on the whole list) then a maximum 3.0 GPA could be awarded for the assignment.

There is a sample run of my solution ("output.txt").

You can still practice applying good style in your solution (e.g. using the predefined named constants such as 'CLEANED' rather than directly using an unnamed constant '.') as well as writing documentation. Unlike the full assignments you will be just graded on program functionality for the mini-assignments.

Documentation requirements

Style requirements

Submitting your work:

  • The document must be electronically submitted using D2L. This applies to on-time or late submissions.
  • D2L configuration for this course
    • Multiple submissions are allowed for this assignment: You can (and really should) submit work as many times as you wish before the due date. Due dates are strict, only what is in D2L by the deadline is what will be marked. Other methods of verifying that your work was completed on time (e.g. checking timestamps, emailed files etc.) will NOT be accepted.  
    • Multiple files can be submitted for this assignment (e.g. A1_version1_May7, A1_version2_May8 etc.) Consequently all versions of your submissions will be retained. However only the latest versions of each individual document (for assignments that require multiple files to be submitted) are the ones that will be marked, everything else will be ignored (because it is not fair to your marker to sort through multiple versions of your files).
  • Do not use compression utilities (such as zip) or archiving utilities (such as tar) otherwise your submission may not be marked.
  • Make sure that you [check the contents of your submitted files] (e.g., is the file okay or was it corrupted, is it the correct version etc.). It's your responsibility to do this! (Make sure that your submit your assignment with enough time before it comes due for you to do a check)

Marking

  • Assignments will be marked by your tutorial instructor (the "Teaching Assistant" or "TA") for your tutorial section. When you have questions about marking this is the first person that you should be directing your questions towards. If you still have question after you have talked to your TA, then you can talk to your course (lecture) instructor.
  • Because this is a simple mini-assignment there isn't a marking spreadsheet. If you were awarded full marks then you will see your grade point in D2L (4.0). If you were awarded less than full credit then your marker will enter some brief comments that described where you went wrong into the D2L Dropbox for this component.

Points to keep in mind:

  1. Due time: All assignments are due at 4 PM on the due dates listed on the course web page.  Late assignments or components of assignments will not be accepted for marking without approval for an extension beforehand. Alternate submission mechanisms (non exhaustive list of examples: email, uploads to cloud-based systems such as Google drive, time-stamps, TA memories) cannot be used as alternatives if you have forgotten to submit work or otherwise have not properly submitted into D2L. Only files submitted into D2L by the due date is what will be marked, everything else will be awarded no credit.
  2. Method of submission: You are to submit your assignment using D2L [help link]. Make sure that you [check the contents of your submitted files] (e.g., is the file okay or was it corrupted, is it the correct version etc.). It's your responsibility to do this! (Make sure that you submit your assignment with enough time before it comes due for you to do a check).
  3. Identifying information: All assignments should include contact information (full name, student ID number and tutorial section) at the very top of your program in the class where the 'main()' method resides (starting execution point). (Note other documentation is also required for most assignments).
  4. Collaboration: Assignments must reflect individual work; group work is not allowed in this class nor can you copy the work of others.  For more detailed information as to what constitutes academic misconduct (i.e., cheating) for this course please read the following [link].
  5. Execution: programs must run on the computer science network (if applicable during that particular semester) running Python 3.x. If you write you code in the lab and work remotely using a remote login program such as Putty or SSH then you should be okay (assuming you don't login to a non-Linux computer). If you choose to install Python on your own computer then it is your responsibility to ensure that your program will run properly here. If it won't run using Python 3.x then it won't be awarded credit. It's up to you if you wish use the graphical program builder IDLE to write/run your programs but if you do you submit your program in the form of text ".py" file or files.
  6. Use of pre-created Python libraries: unless otherwise told you are to write the code yourself and not use any pre-created functions. For this assignment the usual acceptable functions include: print(), input() and the 'conversion' functions such as int(), float(), str(). Look at the particular assignment description for a list of other classes that you are allowed to use and still get credit in an assignment submission.
  7. Extensions may be granted for reasonable cases by the course instructor with the receipt of the appropriate documentation (e.g., a sworn declaration with a commissioner of oaths). Typical examples of reasonable cases for an extension include: illness or a death in the family. Example cases where extensions will not be granted include situations that are typical of student life: having multiple due dates, work commitments etc. Tutorial instructors (TAs) will not be able to provide extension on their own and must receive permission from the course instructor first.
  8. Questions about marking: Your Teaching Assistants will be marking the assignments so I will first direct your questions to them regarding the marking

  9. Late submissions (no extension granted):

    Submission received:

    On time

    Hours late : >0 and <=24

    Hours late: >24 and <=48

    Hours late: >48 and <=72

    Hours late: >72 and <=96

    Hours late: >96

    Penalty:

    None

    -1 GPA

    -2 GPA

    -3 GPA

    -4 GPA

    No