Your Assignment

Write a recursive function sumlist(my_list) to calculate the sum of the numbers in a list my_list passed as a parameter. The sum of a list is the sum of the head (first element) plus the sum of the tail (all the other elements). Test your function by creating a program that uses sumlist to calculate and print the sum of the following list:

my_list = [7, 5, 4, 27, 52, 42, 13, 17]

Assignment Requirements

  1. This is a easy assignment the requires the use of recursion to solve.

Submission Requirements

There are a few standards to adhere to when submitting your lab. Please read, and follow them carefully.

  1. Submission Filename: Submit a file named

  2. Documentation String (“docstring”): The following docstring (properly edited with your name) needs to be the very first thing in your Python program file.

    """CSC 161 Lab: Algorithms
    This lab...
    Fox Mulder
    Lab Section TR 2:00-3:15pm
    Fall 2015

    Read more about docstrings: Program Documentation String

  3. Comments (lines prefaced with #): Unclear parts of your code can receive point deductions, so be judicious about using comments. Do not overuse comments. Too much unnecessary commenting can complicate reading otherwise clear code!

    Read more about comments: Program Comments

  4. Python Code Style: You will need to run your Python program file through the online PEP 8 style checker found in CSC 161 Style.

  5. The __main__, top-level script environment” check is required:

    if __name__ == '__main__':

    You can read more about this trick on the official Python website.

The Blackboard post for this lab assignment will contain the details regarding the due date and other details regarding class administration for this assignment.


The following is the grading rubric for this lab to be used by the course graders. The lab is worth 100 points.

Here’s a brief grading rubric:

  • Syntax errors: -30 points
  • A bad/missing docstring (i.e. no name, lab section, etc): -10 points
  • The submitted filename is wrong: -10 points
  • No Python comments used when they are needed to clarify code: -5 points
  • Code doesn’t attempt to adhere to Python coding style: -10 points
  • Your top-level script environment check is missing: -5 points
  • Missing main() function: -10 points
  • Any reasonable variation of my solutions should get full credit. If the program doesn’t use recursion, it should receive 0 points.

Extra Credit

Extra credit ideas:

  1. You are not guaranteed to receive extra credit, it will be up to the lab TA to decide.
  2. Any extra credit work you do needs to be clearly commented in your code
    • If your extra credit code is not clearly documented using comments, you are not guaranteed to receive extra points.
  3. Do not submit a second Python file, just modify your original submission.
  4. Extra credit supersedes any of the above grading rubric if it conflicts.