Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CISC 217 Week 2 Lab: Score Summary

Weekly Topic

Lists, tuples, sorting, and slicing.

Lab Summary

In this lab, you will implement functions that clean, summarize, sort, and slice score data. You will practice using lists for ordered, changeable data and tuples for immutable summary results.

You will complete the code in:

src/score_summary.py

Do not change function names, parameter names, file names, or test file names unless your instructor tells you to. The tests and Classroom50 autograder import these exact functions.

Learning Goals

By the end of this lab, you should be able to:

  • Store ordered values in Python lists.
  • Convert and clean mixed input values.
  • Sort data without modifying the original list.
  • Use slicing to select the highest, lowest, or middle values.
  • Return immutable summary information as a tuple.
  • Run pytest before committing and pushing your work.
  • Submit a clear Canvas lab post with GitHub evidence.
  • Complete peer review through a GitHub pull request.

Development Workflow: Classroom50 + GitHub + NRP JupyterHub

  1. Open the Classroom50 assignment link from this Canvas module and accept the assignment.

  2. Click Go to your GitHub repository to open your assignment repository in a new browser tab.

  3. Open NRP JupyterHub.

  4. Start your JupyterHub server using the course settings: 0 GPUs, 2 CPU cores, 4 GB Memory, Stack Minimal.

  5. If you have not already connected JupyterHub to GitHub with SSH, generate an SSH key in a JupyterHub terminal:

    ssh-keygen -t ed25519

    Press Enter three times to use the default location and skip a passphrase.

  6. Print and copy your public key:

    cat ~/.ssh/id_ed25519.pub
  7. Add the SSH public key to your GitHub account at https://github.com/settings/keys.

  8. Return to your GitHub repository browser tab, click the green Code button, choose SSH, and copy the clone URL.

  9. In a JupyterHub terminal, clone your repository:

    cd ~/
    git clone PASTE_YOUR_SSH_CLONE_URL_HERE
    cd REPOSITORY_FOLDER_NAME
  10. Confirm you are in the repository root folder:

    pwd
    ls

    You should see files such as README.md, pyproject.toml, src, and tests.

  11. Create and activate a virtual environment:

    python -m venv .venv
    source .venv/bin/activate
  12. Install the project and test tools:

    python -m pip install -e .[test]
  13. Run the tests before editing so you can see what currently fails:

    python -m pytest -q
  14. Edit only the permitted source file:

    src/score_summary.py
    
  15. Run tests until they pass:

    python -m pytest -q
  16. Commit and push your completed work:

    git status
    git add src/score_summary.py
    git commit -m "Complete week 2 score summary lab"
    git push origin main
  17. Go back to your GitHub repository, click the Actions tab, and confirm the autograder result after it runs.

  18. Grant the GitHub Team classroom50-cisc217-inter-python-programming the role Read on your repository if peer review access is not already available.

  19. Post your GitHub repository link and required evidence in the Canvas lab discussion.

Required Functions

Complete all functions in score_summary.py.

clean_scores(raw_scores)

Return a list of valid numeric scores between 0 and 100, inclusive.

Rules:

  • Accept integers and floats.
  • Accept strings that can be converted to numbers, such as "88" or "91.5".
  • Ignore None values.
  • Ignore values that cannot be converted to numbers.
  • Ignore numeric values below 0 or above 100.
  • Return scores as floats in their original valid order.

Example:

clean_scores(["90", None, -5, "abc", 87.5, 105])
# returns [90.0, 87.5]

summarize_scores(scores)

Return an immutable summary tuple in this exact order:

(count, lowest_score, highest_score, average_score)

Rules:

  • Convert numeric results to floats except for count.
  • Round the average to 2 decimal places.
  • For an empty list, return (0, 0.0, 0.0, 0.0).

Example:

summarize_scores([80, 90, 100])
# returns (3, 80.0, 100.0, 90.0)

sort_scores(scores, descending=True)

Return a new sorted list of scores.

Rules:

  • Convert returned values to floats.
  • Do not modify the original list.
  • By default, sort from highest to lowest.
  • If descending is False, sort from lowest to highest.

top_scores(scores, count=3)

Return the highest scores as an immutable tuple.

Rules:

  • Use sorting and slicing.
  • If count is larger than the number of scores, return all available scores.
  • If count is 0 or negative, return an empty tuple.

bottom_scores(scores, count=3)

Return the lowest scores as an immutable tuple.

Rules:

  • Use sorting and slicing.
  • If count is larger than the number of scores, return all available scores.
  • If count is 0 or negative, return an empty tuple.

middle_scores(scores)

Return a tuple with the lowest and highest score removed.

Rules:

  • Sort scores from lowest to highest first.
  • Remove one lowest score and one highest score using slicing.
  • Return the remaining values as an immutable tuple.
  • If fewer than 3 scores are provided, return an empty tuple.

Example:

middle_scores([70, 100, 80, 90])
# returns (80.0, 90.0)

curve_scores(scores, points)

Return a new list with points added to each score, capped at 100.

Rules:

  • Do not modify the original list.
  • Add points to every score.
  • Scores may not go above 100.
  • Return values as floats.

Example:

curve_scores([91, 98], 5)
# returns [96.0, 100.0]

Running the Tests

Run:

python -m pytest -q

A passing run should show output similar to:

11 passed

The exact number of tests may change if your instructor updates the assignment, so pay attention to whether all tests pass.

Canvas Initial Lab Post

After your tests pass and you push your work to GitHub, post in the Week 2 Lab Discussion.

Your initial post should include:

  1. A link to your GitHub/Classroom50 repository.
  2. A short explanation of how you used lists in this lab.
  3. A short explanation of where you returned tuples and why tuples make sense for that result.
  4. One example of sorting or slicing from your solution.
  5. One question, challenge, or debugging issue you encountered.

Example initial post:

My repository is here: PASTE_LINK_HERE. In my solution, I used lists for score data because the functions need to clean, sort, and slice ordered values. I returned tuples from summarize_scores, top_scores, bottom_scores, and middle_scores because those results should not be changed after they are created. One place I used slicing was in middle_scores, where I sorted the values and then used a slice to remove the first and last score. One issue I had was remembering that sorted() returns a new list while .sort() changes the original list.

Peer Review Pull Request

Your peer review is completed through a GitHub pull request and a Canvas reply in the same lab discussion board.

The peer review is due one week after the initial lab post is due.

Pull Request Requirements

Open a pull request on a classmate's repository. Your pull request should make a small, helpful contribution. For Week 2, this should usually be a documentation or test-comment improvement, such as:

  • Fixing a typo or unclear sentence in the README or a documentation file.
  • Adding a short comment that makes a list, tuple, sorting, or slicing step easier to understand.
  • Suggesting a clearer explanation of the test output.
  • Asking a thoughtful question in the pull request description about one of the Week 2 concepts.

Do not rewrite your classmate's solution or make unrelated changes. The goal is to practice professional code review, communication, and GitHub collaboration.

Canvas Peer Review Reply

In the same Canvas discussion board, reply to your classmate with:

  1. A link to the pull request you opened.
  2. One specific comment about their use of lists, tuples, sorting, or slicing.
  3. One specific suggestion or question connected to their repository or test evidence.

Replies such as "Good job," "I agree," or "Looks good" by themselves are not substantial enough for credit.

Example peer review reply:

Hi Jordan, here is the pull request I opened on your repository: PASTE_PULL_REQUEST_LINK_HERE. I noticed that your top_scores function uses sorting before slicing, which makes the result easier to reason about. I suggested adding one short comment explaining why the function returns a tuple instead of a list. One question I had was whether your sort_scores function changes the original list or returns a new sorted list, because that distinction is important for this week's topic.

Academic Integrity

You may discuss setup steps, error messages, and general Python concepts with classmates. Your submitted code must be your own work. Do not copy another student's solution. Peer review pull requests should be small, helpful improvements rather than replacement solutions.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages