Merge Sort
Implement merge_sort(numbers) that returns a sorted copy of the input list using the merge sort algorithm.
Peak Element in Array
Implement a function that returns the index of any peak element in a list of integers.
Online Stock Span
Implement StockSpanner.next(price) that returns the maximum number of consecutive days (including today) with price <= current price.
Top N per group
Implement top_n_per_group that returns the top N scores for each group from a list of (group, score) pairs.
Argsort Indices
Implement a function that returns the indices that would sort a list of integers, with ties broken by original order.
Level Order Traversal
Implement a function that performs a level order traversal of a binary tree and returns node values as a list of lists.
Once Decorator: Run a Function Only Once
Implement a decorator that caches and returns the result of the first call for subsequent calls.
Print Args Decorator
Write a decorator that prints function name and arguments, then returns the original result.
Log Calls Decorator
Create a decorator that prints call details and returns the original result.
Safe divide function
Implement safe_divide that returns None on ZeroDivisionError and TypeError.
Key error handler
Implement a safe dictionary access function that returns a default value on missing keys.
Parse JSON safely
Implement a robust JSON string parser that returns a fallback on invalid input.
Exit handler registration
Write a function that registers a callback to run at interpreter exit and returns True on success.
Nth Triangular Number
Implement a function that returns the nth triangular number efficiently.
Integer Square Root Floor
Implement a function that returns the greatest integer whose square is ≤ n, using only integer operations.
Catalan number
Implement a function that returns the nth Catalan number using dynamic programming.
Perfect Number Check
Write a function that returns True if a number is perfect, i.e., equal to the sum of its proper divisors.
Happy number check
Implement a function that returns True if a number is happy, False otherwise.
Triangular Number
Implement a function that returns the nth triangular number using the closed-form formula.
Partition function
Write a function that returns the number of ways to write a positive integer as a sum of positive integers (order irrelevant).
Integer Square Root
Implement integer_sqrt(n) that returns the largest integer whose square is ≤ n.
Zeller Congruence Weekday
Implement a function that returns the weekday name for a given date using Zeller's congruence.
Dot Product of Vectors
Implement a function that returns the dot product of two numeric vectors.
Modular Inverse
Implement a function that returns the modular inverse of a modulo m, or -1 if it does not exist.
Showing 73–96 of 150 challenges
Guide: free Python coding challenges
Practice Python by solving problems
PythonSkillset challenges are hands-on coding exercises from beginner to advanced. Open a challenge, read the problem, write Python in the split-pane editor, and run tests with Pyodide — no install required.
How to use the arena
- Pick a category — basics, algorithms, strings, and more
- Open a challenge, read the statement, and edit the starter code
- Run tests, fix failures, then try a related quiz or tutorial lesson
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.