CPSC 217: Mini-Assignment 3C
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
- File input for
2D lists
- Exception
handling
- If you want credit for your work: Do not
use any pre-created functions/methods unless you are given explicit
permission to do so. [Generic
list of allowable pre-created code in the form of python libraries]
Additional functions allowed for this assignment:
len, append, open, readline, close.
Although it's not necessary you can use any string methods or substring
operators that were covered in lecture.
Only new concepts that need to be applied in the assignment are
listed, concepts previously applied in other assignments may need to used in the
implementation of your solution.
Write a program that consists of
two functions (in addition to a start function).
Synopsis: This function will read
the first seven numbers (one number for each day of the week, each number stands for Calgary
job numbers) into each row of a 2D list.
Your program will ignore any
information that comes after these numbers on a row.
The job numbers for a particular day is
only a single digit long. It will then continue
reading, line by line, job numbers into a new row of the list. (That is, the
list containing the job numbers will be dynamically created with the number of
rows in the list matching the number of rows of job numbers in the input file.
The name of the input is specified by the user when the program runs). [One example of a possible input file]
Breakdown of the 3.0 credit is
awarded:
- Prompt the
user for the name of the input file & if the file is empty it will
display an error message. (0.5 GPA)
- Open the input
file and only read the job numbers for Calgary into the list, other
information is ignored. (2 GPA)
- If there is
any problems associated with the file (cannot open, file is empty, there
is an error during the read process) then the program will display an
appropriate error message and repeatedly prompt the user for the name of
the input file and attempt the file read process anew. (0.5
GPA)
The input file contains job
numbers for Calgary and Edmonton.
- The first row
("Calgary & Edmonton job numbers..." is a heading and should not be read into the list.
- The second and
successive rows contains a week of job numbers.
-
Each of the day's job numbers for
Calgary are
each followed
by a space. After the Calgary job numbers is a tab which is followed
by 7 numbers for Edmonton.
Here is the data show in the
example input file. You program must be able to handle an input file with 1 or
more weeks worth of numbers. Because the list
containing the job numbers is created dynamically, your program should be able
to process a file with any number of rows. In the example below for the first
week of job numbers your program will read in 0, 5, 5, 9, 8, 7, 0. Although you
have an example data file don't write your program to specifically read from
this exact file! As long as the file format is the same (e.g. heading on the
first row, one group of columns for Calgary job numbers, one group for Edmonton
etc.) your program must be able to work with any input file. And of course you
cannot just write your program so it can only read from a modified input file
(e.g. the heading in the first line is moved or deleted, the Edmonton job
numbers are removed etc.)

The list will be displayed with each row displayed on its own line. (0.3 GPA)
Each element (number) will be followed by a dash. (0.3 GPA)
When a row of numbers has been displayed the total for that row will be
displayed at the end of the row.
(0.4 GPA) Here is the output using the
sample input file (the first line in the image shows the user being prompted for
and entering the name of the input file and isn't part of the list data).

In order to make marking reasonable, in order to get credit for the file input
function the display function must be able to display the 2D list even if the
display function does not quite fill requirements for [display
function]. That is, you
won't get credit if your program reads the information into the list but doesn't
display any output because the marker can't quickly tell if your file code is
properly reading the information into the list. It's far faster for the
marker to evaluate your program by running it and viewing the results rather
than hand tracing code (the latter of which they will not do). But that's
not a tough requirement to meet. The main
thing is to get any credit for the [file function] the
marker must be able to see the output of the list. For example, you have the
following instruction
imbedded in a loop:
# A loop with 'r' as the loop
control stepping through the rows in the list
print(jobNumbers[r]).
This latter crude approach may
allow you to be awarded credit for the file read function (but nothing for the
display function).
Summary:
- No credit if your
program implements a display function without any file input.
- Possible credit for the [file
read function] if the marker can tell that the correct information has
been read into the list even if the output doesn't appear in the fashion
specified for the [display function].
- Full credit will be awarded
only if the information is read correctly into the list as defined in the [file
read function] and displayed in the specified fashion in the [display
function].
Hint
(seeing the invisible characters in a text document).
Open the input file using Word
(you should be able to access Word via the student license for Office 365
without charge
while you are U of C student) and here's how you turn toggle the display of 'Formatting marks':
- Home ribbon -> (Paragraph group) and click on the
Show/Hide
icon
Characters that aren't visible
such as spaces, tabs and the newline (enter) appear in this display mode. Here's
how to see formatting marks in MS-Word on an Apple computer (because the
university is unable to provide a MAC to the course instructor the correctness
of the contents of this link could not be verified): [Viewing
formatting marks on a MAC]

Bigger
hint
In tutorial the TAs will cover an example
called ['3fileReadIntoList.py'] (linked in here for your convenience) that you
may find extremely useful for this assignment and for the second part of the
project. so you should make special effort to attend
tutorial that week.
Although it won't affect your grade for mini-assignments you should still
practice applying good style in your solution as well as writing
documentation. It will keep your skills for the full assignments (when you will
be graded on these things) and get you used to having good habits.
- 1:
Naming conventions: You should employ good
naming conventions for identifiers (variables, constants and even the
name of the file containing the program) as covered in the "Intro to
programming" section of the course.
- #2:
Named constants should be used as appropriate
(and if they aren't a penalty will be incurred).
|
Yes do it this way! |
No. Not this way! |
|
LEFT = 0
RIGHT = 1
CENTER = 2 if (silverLockPosition ==
RIGHT): |
if (silverLockPosition
== 0): #What does 0 stand for??? |
- #3:
The program code should have appropriate
white space (specified in the "Intro to programming lecture') and
alignment (specified throughout the lecture notes).
- #4:
Code is self documenting e.g. Clear
expressions (e.g. mathematical, Boolean). Expressions should be clear
and simple (break up or restructure complex expressions).
Good variable names and the use of named constants are examples of
writing self documenting code but specifying clear expressions is
important enough to be included in a separate category.
- #5: Your program should follow the 6 rules of
thumb for designing user friendly software (distilled from Jakob
Nielsen's 10 usability heuristics - see the Usability Heuristics in the
[Part III of the
looping/repetition notes]). e.g. good error handling (such as prompts to the user to
enter the required information clearly indicate what is required, good
error messages/error handling should be provided for erroneous input) minimizing the
user's memory load, being consistent, making the interactions with the
program (the "dialog") as simple and as natural as possible, providing clearly marked exits &
providing feedback as appropriate. This includes but is not limited to
having the menu selections for choosing options being
intuitive.
- #6:
Of course if a student implements an extreme
case of inefficient code (e.g. multiple loops or branches are used when
one will do) then penalties may be applied but this is generally rare.
- #7:
The program should not employ abnormal termination mechanisms
e.g. something such as a 'break'
instruction for loops or calls to the 'exit()',
'quit()' functions anywhere in the
program.
-
Function specific style requirements:
- #1: Functions are one screen in length
(normal screen 40 lines max of code (the count excludes whitespace and
documentation).
- #2
Functions implement one well defined task (e.g. processLivingRoomCommands vs. processlivingRoomRunIntroductionRunConclusion).
- #3:
Code in one function is not duplicated in another
function (not in the notes but this is just common sense that you don't
write two functions where there's overlapping code - the overlap should
likely be taken out of both functions and moved to another separate
function).
-
Documentation requirements:
-
Header documentation: This
should be specified in the header of the program (very top of your
program in the form of Python documentation). The basics of
documentation were covered in the "Intro to programming" section of
the course. Later lectures may specify additional information that
needs to be provided in the documentation.
- Identifying information:
All assignments should include contact information (full name,
student ID number and tutorial section [Here's
a link
if you don't know how to find this information])
at the very top of your program.
- Program
version. (version date or version number).
- Under
the version you should specify which assignment features
were implemented in that version as specified in the "Intro
to programming section"
-
Any program limitations or weaknesses.
-
New documentation requirement
starting with A2 and applies to all successive assignments:
Just before the header definition of the function:
list the features of the assignment (e.g. checking list bounds,
displaying the list etc.) that were implemented in a particular
function, the return type(s) as well as the type(s) of the
arguments. Greater details are provided in the functional
decomposition lectures.
.
Failing to use this exact name will affect your grade by -0.2 GPA.
What to submit:
If your submission won't run using Python 3.x on any computer then it won't be
awarded credit.
It's up to you if you wish use a graphical program builder other than IDLE (or another development
environment rather than a simple text editor) to write/run your programs but
regardless you must submit your program in the form of a text ".py"
file or files. Also if you run into problems using another
editor then you may be "on your own" because we only have the ability to
support one development tool which is IDLE.
-
All computer users: Be careful that you actually
submit the file containing your program and not a related file, here's one
example of a problem: operating systems sometimes create a "lock file"
[Description of a lock file for Windows users] [Description for UNIX users -
may apply to MAC-OS].
- Tam's brief explanation
of a lock file: These files are created when
a file is being edited to prevent multiple users or programs from trying to
edit that file. (Names of lock files typically include the file being edited
but include a tilde character in the name e.g. the file being edited is 'a1.py' so
the lock file is named '~a1.py'. Because the lock files do not contain the
actual data take care that you don't accidentally submit the lock file
instead of the file (some students have actually done this).
- Windows users: take care that you don't accidentally submit a
[shortcut to a
file] instead of the actual file. (Check the file name and compare the file
size to your original file. Simply downloading the shortcut file as a test
won't work because that shortcut will work on your computer but not on
anyone else's machine and this may mean your work won't be graded.)
- MAC-users: this
operating system has an equivalency to Windows shortcuts (e.g. symbolic
links but since creating them is a little more involved, typing at a command
line "
ln
-s <target file name>" it's
less likely that this problem will come up).
Before the due
date, late assignments or
components of assignments/assignment extensions: Due dates/due
times are
strict and extensions require documentation (e.g. a note from a medical
doctor) in order to get permission from
the [course
instructor]. If/when permission is awarded for a late submission then I
will let the marker know that the regular penalty will not be applied.
When you ask for an extension you need to specify the name of the
TA in the tutorial that you are officially registered.
Alternate submission mechanisms to D2L (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/time is
what will be marked,
everything else will be awarded no credit. The final cut off date after
which full assignments will not be accepted is after the [maximum
progressive penalty (listed below)] can
be applied.
Questions or
concerns about grades after they have been released: Assignments will be
marked by your tutorial instructor (the "Teaching Assistant" or "TA") in the
[tutorial
section] you are officially registered in. If
you don't know which tutorial section you are officially registered in then
you can find this information in the Student Center in the [PeopleSoft
university portal]. 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 of
course talk to your [course
(lecture) instructor] but please indicate in your
email that you first contacted your TA before going into your concerns.
How you will be graded for mini-assignments.
Similar to many mini-assignments the grading is simple and doesn't require
a separate spreadsheet. Instead you can look in D2L
under Assessments->Dropbox and
then clicking on the appropriate assignment link.
Collaboration:
Assignments must reflect individual work;
group work is not allowed in this class nor can you copy the work of
others. Some "do nots" for your solution:
don't publically post
it, don't email it out, don't show it to other students nor should you verbally
discuss it. For more detailed information as to what constitutes academic
misconduct (i.e., cheating) for this course please read the following [link].
Method of submission:
Reminder: You are to submit your assignment using D2L Here's a UC-IT
created [D2L
help resource] .
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, it is
the correct file 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). If don't check and there were problems with the submission then you
should not expect that you can "learn your lesson" and simply resubmit Whatever
you submitted into D2L by the final due date (and due time) is what will be marked.
-
Do not use compression utilities (such as zip) or archiving utilities
(such as tar) otherwise your submission may not be marked. The space savings
in D2L is not worth the extra time required by the marker to process each
submission.
-
How often can you submit: Multiple
submissions are allowed for this assignment: You can (and really should)
submit work as many times as you wish before the due date. However
only the latest file submitted is the one 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).
-
What to submit: Python programs only (file name ends in .py)
Any other type of file will be rejected by D2L.
Late
submissions for full assignments when there is no extension granted: Make
sure you give yourself enough time to complete the submission process so
you don't get cut off by D2L's deadline (or your submission will be
automatically flagged as late by D2L and it will be graded appropriately)..
Submission received: |
On time |
Hours late : >0 and <=24 |
Hours
late: >24
and <=48 |
Penalty: |
None |
-1 GPA |
-No
credit (not accepted) |
Unless otherwise told you
are to write the code yourself and not use any pre-created functions (or
methods). For most assignments 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
functions/methods that you are allowed to use and still get credit in an
assignment submission. If it's not listed then you should assume that you won't
be able use the function and still be awarded credit.