Joel Stevick

The Python readiness check · 30 minutes · one task

Junior Python coding test practice

Developers with a year or less of Python, applying for a first or junior role, or for an internship.

A new test every time, written by Claude, like the screens on HackerRank, CodeSignal and Codility: 30 minutes, one task, hidden tests that score it and a review of your code. Your first junior test is free; after that $5 a test, or $19 for five.

The topics

Strings, Lists and slicing, Dictionaries, Loops, Functions, Edge cases.

A sample task: Run-length encoding

A task from this level, whole, as the test shows it. Your test is a new one, written for you.

Write compress(s), which returns the run-length encoding of the string s: each run of the same character becomes the character followed by the length of the run. A run of one character is written as the character alone, with no 1. Runs longer than nine are written with their full length ("a" * 12 becomes "a12"). Characters are compared exactly, so "a" and "A" are different. The empty string gives the empty string.

compress("aaabcc")  # "a3bc2"
compress("abc")     # "abc"

Starter code

def compress(s):
    # Return the run-length encoding of s, for example "aaabcc" -> "a3bc2".
    pass

Example tests

def test_example_runs():
    assert compress("aaabcc") == "a3bc2"


def test_example_no_runs():
    assert compress("abc") == "abc"

Hidden tests (11 of them for this task) check the edge cases the statement names. You never see them, as on a real screen.

A sample report

A real graded submission with mistakes: its test results come from the harness run by a local Python 3.9.6 (npm run assessment:anchors:local) on 2026-11-22; its review was written by hand as the sample review, for a submission whose test results come from a real run of the harness; not a live model run.

Not yet ready for a junior Python screen

5 of 11 hidden tests passed. Ready means at most one hidden test failed on every task; close means at least 60% of them passed overall.

The loop finds the runs, but the output format is wrong for single characters and the function crashes on an empty string: on a real screen this scores under half.

Task 1: Run-length encoding

5 of 11 hidden tests passed.

  • test_empty_string: IndexError: string index out of range
  • test_one_character: AssertionError
  • test_case_matters: AssertionError
  • test_spaces_are_characters: AssertionError
  • test_run_at_the_end: AssertionError
  • test_alternating: AssertionError

Summary. You compare each character with the one before it, which is a sound way to find runs. Two misreadings of the statement cost you six of the eleven hidden tests.

What failed and why, most important first:

  1. test_one_character: A run of one is written as the character alone. You always append str(count), so "x" becomes "x1", and every string with a single character in it fails, which is also why test_case_matters, test_spaces_are_characters, test_run_at_the_end and test_alternating fail.
  2. test_empty_string: After the loop you read s[-1], which raises IndexError when s is empty. Return "" before the loop when there is nothing to compress.

Edge cases. Long runs (more than nine) and digits work, because str(count) writes the full number. The empty string and runs of one are missed.

Complexity. Building the result with += in a loop can be quadratic for very long strings in some Pythons; collecting the pieces in a list and joining once is linear. It does not matter at this size, but an interviewer may ask.

Readability. Short and clear. Naming the loop's two cases (a run continues, a run ends) in the code would make the final append after the loop look less like a special case.

Your code
def compress(s):
    result = ""
    count = 1
    for i in range(1, len(s)):
        if s[i] == s[i - 1]:
            count += 1
        else:
            result += s[i - 1] + str(count)
            count = 1
    result += s[-1] + str(count)
    return result
A reference solution
def compress(s):
    out = []
    i = 0
    while i < len(s):
        j = i
        while j < len(s) and s[j] == s[i]:
            j += 1
        run = j - i
        out.append(s[i] + (str(run) if run > 1 else ""))
        i = j
    return "".join(out)

A proctored screen would have flagged 0 pastes into the editor and 1 time the tab was left. Nothing was blocked here; on a real screen these are often reviewed by a person.

What to practise

Start a test

All four levels and the questions people ask: the Python readiness check.