How to use the Python Practice Problems
- 1. Pick a problemFilter by Easy, Medium or Hard.
- 2. Write the functionReplace pass with your code. Keep the function name.
- 3. Run testsSee each call, the expected answer and yours.
The problems
- Easy (10): sum a list without sum(), reverse a string, even or odd, count vowels, largest of three without max(), leap year, factorial, list of squares with a comprehension, palindrome, remove duplicates in order.
- Medium (11): prime check, word frequency dict, second largest, anagrams, Fibonacci list, sum of digits, merge two sorted lists, group words by length, balanced brackets, transpose a matrix, Two Sum.
- Hard (4): string compression, flatten nested lists, longest substring without repeats, Roman numerals.
These match what campus placement tests and Python interviews ask for freshers. Each has 2–4 tests including edge cases like empty lists, 0, 1 and negative numbers. Your code and the ✓ marks are saved in this browser, so you can come back and continue.
Worked example
Problem 1 asks you to total a list without sum(). This attempt:
def total(nums):
t = 0
for n in nums:
t = n
return tpasses 2 of 3 tests, which is a trap. For [1, 2, 3, 4] it returns 4, the last item, because t = n replaces the total instead of adding to it. The other two pass only by luck: an empty list gives 0, and [-2, 2, 5] really does total 5, its last item. Changing the line to t += n gives 3 / 3 tests passed.
How answers are checked: your function is called with each test's arguments in real Python 3, and the result is compared with the expected answer, so a tuple (1, 2) matches [1, 2] and dict key order doesn't matter. Anything you print() is shown under the results. Code that runs longer than 6 seconds is stopped, so an endless loop can't hang the page.
Frequently asked questions
Which Python version runs my code?
Python 3.12 through Pyodide, in your browser.
Can I import modules?
Yes, the standard library works, such as math, collections and itertools.
Why is the first run slow?
Python itself (about 10 MB) loads the first time. Later runs are quick.
Do I have to pay for the python practice problems?
No, it is free. Running your first tests asks for your name and WhatsApp number one time only. Then the python practice problems and all other Uncodemy tools stay open for you with no form.