Skip to main content
All demo runs

Recorded demo · Programming or code (read, not run)

Python: word frequency function

Graded by GradeHomeworkOnline on fictional student work. Nothing here is live, and nothing you do changes it. Every grade here is still a proposal: none has been approved.

Start grading for freeSkip to the results

Step 1The assignment

Write a Python function word_counts(text) that returns a dictionary mapping each word (lower case, punctuation removed) to the number of times it appears. Include a docstring and handle an empty string.

Step 2The rubric: 3 criteria, 10 points

Rubric criteria and points
CriterionPoints
CorrectnessReturns correct counts, lower-cases words and removes punctuation.5
Edge casesHandles an empty string (returns an empty dictionary) and repeated spaces.3
ReadabilityClear names, a docstring, and simple structure.2

Step 3The class: 4 fictional students

  • Sample-student-01.py
    import string
    
    
    def word_counts(text):
        """Return a dict mapping each lower-case word in text to its count."""
        cleaned = text.lower().translate(str.maketrans('', '', string.punctuation))
        counts = {}
        for word in cleaned.split():
            counts[word] = counts.get(word, 0) + 1
        return counts
    
  • Sample-student-02.py
    def word_counts(text):
        d = {}
        for w in text.split(' '):
            if w in d:
                d[w] += 1
            else:
                d[w] = 1
        return d
    
  • Sample-student-03.py
    from collections import Counter
    import re
    
    def word_counts(text):
        """Count words, ignoring case and punctuation."""
        words = re.findall(r"[a-z']+", text.lower())
        return dict(Counter(words))
    
  • Sample-student-04.py
    def word_counts(text):
        # count words
        words = text.lower().split()
        result = {}
        for word in words:
            word = word.strip('.,!?')
            result[word] = words.count(word)
        return result
    

Step 4The settings

Grading level
Fast
each submission graded once
Strictness
Balanced
Feedback
Standard

Step 5Checked before grading: 8 requirements read from the rubric

Before anything is graded, the rubric's own words are turned into requirements, each with the words it came from. The instructor checks them, then locks the job.

Correctness (3)
  • Returns correct word counts. — “Returns correct counts”
  • Lower-cases words. — “lower-cases words”
  • Removes punctuation. — “removes punctuation”
Edge cases (2)
  • Returns an empty dictionary for an empty string. — “Handles an empty string (returns an empty dictionary)”
  • Handles repeated spaces. — “Handles an empty string (returns an empty dictionary) and repeated spaces.”
Readability (3)
  • Uses clear names. — “Clear names”
  • Includes a docstring. — “a docstring”
  • Uses a simple structure. — “simple structure”

Grading results

Run state: loading

Submissions

0 shown
Export grades

Choose a file. Each is a CSV; the learning-system files are filled in here, in your browser.

0 of 0 shown.

Submissions in this run and their grades
SubmissionStatusGradeReviewEvaluationsActions

Approve this run

Not approved

These grades and feedback were proposed by AI and can be wrong. Review each one, and correct any you disagree with, before you approve them or give them to students.

Approval is your explicit acceptance of these grades. Looking at results or closing this page does not approve them. After approval, grades in this run can no longer be corrected.

Regrade

Grade the same submissions again at a different strictness or feedback length, or keep every grade and write only the feedback again. Either starts right away as a new run; this run, its grades, corrections and approvals stay exactly as they are.

What it uses: each of this run's 0 submissions counts again as a graded submission, from your plan's allowance or, on pay as you go, from credit at this run's grading level. Nothing is charged until you start it.

What to redo

The midpoint between the highest and lowest scores the rubric reasonably supports.

Next demo: Persuasive essay: free public transit

Open it

We use cookies needed to sign you in. If you accept, our public pages also load Google's advertising tag, which sets Google's cookies, so we can tell which ads lead to new accounts. It never loads after you sign in or on pages with your classes or students' work, and nothing optional loads unless you accept. How we use cookies