CS 115 Project 2 Style Grading Sheet


You can test most of the items in the "Formatting" section by copying your program to the cwolf server, logging into cwolf and navigating to the correct directory, and running the following command. Fill in the name of your file where indicated:

~srivoire/bin/python_style_check.sh yourprogram

Pay attention to any output this program prints. If it doesn't produce any output, then you're in good shape.

The error codes refer to the Python PEP 8 style guide, which is the basis of these rules.

Here is how to read an error message from this command:

proj1.py:10:1: W293 blank line contains whitespace

^

The "10:1" means that the error occurred on line 10, column 1 of your source code file. You can reopen emacs directly to this line by using a "+10" (since you want line 10):

emacs +10 proj1.py

The "W293" refers to the PEP8 rule that your code violates. In this example, a "blank" line in the source code actually has invisible tabs or spaces.

Finally, the error message will show the offending line of your code, and put a

^
symbol underneath the specific error. Since this source code had extra space in a "blank" line, it printed a blank line and marked the beginning of that line.


Programming Style (30 points)

Docstring (2 points)

[2]There is a docstring at the top of the submitted file with your name (first and last), the course (CS 115) and assignment (Project 2), and a brief description of the program.
-1Missing one piece of required information
-1Missing two or more pieces of required information

Usage of functions (5 points)

[5]Program is broken up into logical, well-defined functions. Functions perform specific, well-defined jobs and have descriptive names. Functions are no more than 20 lines of code.
-1Minor lapses
-3Major flaws
-5Program does not have student-written functions

Function parameters and return values (2 points)

[2]Functions have no more parameters than necessary to do their jobs. Return values are used appropriately.
-1Minor flaws
-2Program does not have student-written functions

Function documentation (4 points)

[4] Each function includes a docstring explaining the job it does, its input parameters, its return value, and any assumptions it makes about its inputs.
-1Minor lapses
-2Some functions do not have comments, or comments do not contain the required info
-4Most functions do not have comments

Other documentation (3 points)

Not counting the docstrings for your program and functions, your program should contain at least three comments explaining aspects of your code that are potentially tricky for a person reading it to understand. You should assume that the person understands what Python syntax means but may not understand why you are doing what you are doing.

[3]You have at least 3 useful comments (1 point each)

Variable and function names (4 points)

[4]All variables and functions have descriptive names that indicate what they are used for

Formatting (6 points)

[1] Indentation:
  • Indentation uses only spaces (no tabs). Note that IDLE converts your tabs to spaces automatically.
  • You use a multiple of 4 spaces to indent each level.
[2] Line length and spacing:
  • Your lines do not have trailing whitespace (extra space after the last printable character).
  • Your lines all have fewer than 80 characters. You can have statements that are longer, but you must break them across multiple lines to increase readability. Ask the instructors if you need help breaking up long lines.
  • Use two blank lines before function definitions and two blank lines before the final call to main().
  • Use blank lines to break up your code where appropriate, but do not use more than one blank line in a row, except as described above.
[3] Spacing within statements:
  • Use a single space after, but not before, each comma.
  • Mathematical and relational operators (+, -, <=, etc.) are always preceded and followed by a single space.
  • There are no extra spaces after a left parenthesis or bracket, or before a right parenthesis or bracket.
  • Put a single space after the # character in your comments.
  • Use blank lines to break up your code where appropriate, but do not use more than one blank line in a row, except as described above.

Algorithm (4 points)

[2]Your algorithm is straightforward and easy to follow.
[2]Your algorithm is reasonably efficient, with no wasted computation or unused variables.

Catchall

You will lose 5 points for having ANY statements outside of a function definition. There are only three exceptions to this rule:

You will also lose 5 points for using the global keyword, which subverts the point of functions.

For students using language features that were not covered in class, up to 5 points may be taken off if the principles of programming style are not adhered to when using these features. If you have any questions about what this means, ASK!