Word frequency
Return a dict mapping each word to its count in the sentence.
Mode of a list via counting
Implement a function that returns the mode of a list, resolving ties by the element that appears first.
Top k keys by count
Given a dictionary mapping keys to counts, return the top k keys with the highest counts, breaking ties alphabetically.
Top K Frequent Words
Given a list of words, return the k most frequent words sorted by frequency (descending) and then alphabetically.
Sort by frequency
Sort a list by element frequency descending, with ties broken by order of first occurrence.
Frequency sort descending
Write a function that sorts a list by frequency descending while preserving original order for ties.
Showing 6 challenges · easy · Dicts & Sets
Dicts & Sets — Python coding challenges
What you will find here
This page lists dicts & sets challenges — real Python problems you solve in the browser IDE with instant test feedback. Each challenge includes a clear brief, starter code, and automated checks.
Challenges vs tutorials and quizzes
Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.