Sponsored Reserved space — layout preview until AdSense is connected
Practice Arena

Python Coding Challenges

Write real Python in the browser. Instant feedback. From beginner to expert.

56 challenges 25 easy 23 medium 8 hard
Sponsored Reserved space — layout preview until AdSense is connected
Python Basics easy

FizzBuzz, precisely

Return a newline-separated string for 1..n: Fizz, Buzz, FizzBuzz, or the number.

control flow strings modulo
+10 pts 12m
Python Basics easy

Temperature converter

Convert Celsius to Fahrenheit: F = C × 9/5 + 32.

arithmetic floats
+5 pts 5m
Python Basics easy

Even or odd?

Return 'even' or 'odd' for an integer.

modulo conditionals
+5 pts 5m
Python Basics easy

Sum of digits

Return the sum of all decimal digits of a non-negative integer.

arithmetic loops
+8 pts 10m
Python Basics easy

Collatz steps

Count how many steps the Collatz sequence takes to reach 1 from n.

loops math
+10 pts 12m
Python Basics easy

Factorial (iterative)

Compute n! iteratively without recursion.

loops math
+8 pts 8m
Python Basics easy

Power of two?

Return True if n is an exact power of 2.

bitwise math
+8 pts 8m
Python Basics easy

GCD via Euclid

Compute the greatest common divisor of two positive integers.

math recursion
+10 pts 10m
Python Basics medium

Fibonacci(n)

Return the nth Fibonacci number efficiently.

recursion dp memoization
+15 pts 15m
Python Basics easy

Prime checker

Return True if n is a prime number.

math loops
+10 pts 10m
Strings & Text easy

Reverse a string

Return the characters of the string in reverse order.

strings slicing
+5 pts 5m
Strings & Text easy

Palindrome check

Return True if the string reads the same forwards and backwards (ignoring case and non-alphanumeric).

strings two-pointer
+8 pts 8m
Strings & Text easy

Count vowels

Count the number of vowels (a, e, i, o, u) in a string (case-insensitive).

strings counting
+5 pts 5m
Strings & Text easy

Title case converter

Return the string with each word capitalised.

strings split
+5 pts 5m
Strings & Text easy

Anagram check

Return True if two strings are anagrams of each other.

strings sorting counter
+10 pts 10m
Strings & Text medium

Run-length encoding

Compress consecutive identical characters, e.g. 'aaabbc' → 'a3b2c1'.

strings compression
+20 pts 20m
Strings & Text medium

Longest common prefix

Find the longest common prefix among a list of strings.

strings zip
+18 pts 18m
Strings & Text medium

Integer to Roman

Convert a positive integer to its Roman numeral representation.

strings greedy
+22 pts 22m
Strings & Text medium

Zigzag string conversion

Encode a string in zigzag order across numRows rows, then read row by row.

strings math
+22 pts 20m
Lists & Arrays easy

Two Sum

Return indices (i, j) with i < j such that nums[i] + nums[j] == target.

dict complement
+18 pts 16m
Lists & Arrays medium

Maximum subarray (Kadane)

Find the contiguous subarray with the largest sum.

dp arrays kadane
+25 pts 20m
Lists & Arrays medium

Rotate array

Rotate a list right by k positions in place.

arrays in-place
+20 pts 18m
Lists & Arrays medium

Flatten nested list

Yield every integer from an arbitrarily nested list, depth-first.

recursion generators
+25 pts 22m
Lists & Arrays easy

Remove duplicates (sorted)

Return a sorted list with duplicates removed.

arrays two-pointer
+10 pts 10m
Lists & Arrays easy

Merge two sorted arrays

Merge two sorted arrays into one sorted array.

arrays merge two-pointer
+12 pts 12m
Lists & Arrays medium

Merge intervals

Merge all overlapping intervals and return a sorted result.

intervals sort
+30 pts 26m
Lists & Arrays medium

Product except self

Return an array where output[i] is the product of all elements except nums[i], without using division.

arrays prefix-sum
+25 pts 20m
Lists & Arrays hard

Sliding window maximum

Return the maximum of each window of size k as it slides across an array.

sliding-window deque arrays
+40 pts 35m
Dicts & Sets easy

Word frequency

Return a dict mapping each word to its count in the sentence.

dict counter
+10 pts 10m
Dicts & Sets easy

List intersection

Return the sorted list of elements common to both lists.

sets intersection
+8 pts 8m
Dicts & Sets medium

Group anagrams

Group words that are anagrams of each other.

dict sorting strings
+22 pts 20m
Dicts & Sets easy

First non-repeating character

Find the index of the first character that appears only once.

dict strings counter
+12 pts 12m
Dicts & Sets easy

Most frequent element

Return the element that appears most often in a list.

counter dict
+8 pts 8m
Dicts & Sets medium

Subarray sum equals K

Count the number of contiguous subarrays whose sum equals k.

prefix-sum dict arrays
+28 pts 25m
Functions & Closures medium

Memoize decorator

Implement a @memoize decorator that caches results of a function.

decorators closures caching
+25 pts 20m
Functions & Closures medium

Function composition

Return a function that applies f after g: compose(f, g)(x) == f(g(x)).

functional closures higher-order
+20 pts 18m
Functions & Closures hard

Curry a function

Auto-curry any multi-argument function so it returns partial applications until fully saturated.

functional closures inspect
+35 pts 30m
OOP & Classes easy

Stack class

Implement a Stack class with push, pop, peek, is_empty, and size.

OOP stack data-structures
+12 pts 15m
OOP & Classes medium

Linked list reversal

Implement a singly linked list and a function to reverse it in place.

linked-list OOP pointers
+28 pts 25m
OOP & Classes medium

Matrix addition operator

Implement a Matrix class that supports + and * operators.

OOP dunder matrix
+22 pts 20m
Data Structures & Algorithms easy

Valid parentheses

Return True if brackets in the string close in the correct order.

stack strings
+15 pts 14m
Data Structures & Algorithms easy

Binary search

Return the index of target in a sorted list, or -1 if not present.

searching binary-search
+12 pts 12m
Data Structures & Algorithms medium

Quicksort

Implement quicksort and return a sorted list.

sorting recursion divide-and-conquer
+25 pts 25m
Data Structures & Algorithms medium

BFS level-order traversal

Return the level-order traversal of a binary tree as a list of lists.

BFS trees queues
+28 pts 25m
Data Structures & Algorithms medium

Coin change (DP)

Find the minimum number of coins to make exactly the target amount.

dp greedy
+30 pts 28m
Data Structures & Algorithms hard

LRU cache decorator

Implement @lru_cache(maxsize=N) for unary functions using OrderedDict.

decorators caching OrderedDict
+50 pts 40m
Data Structures & Algorithms medium

Graph DFS

Return all nodes reachable from a start node via DFS.

graph DFS recursion
+28 pts 25m
Data Structures & Algorithms hard

Longest increasing subsequence

Return the length of the longest strictly increasing subsequence.

dp binary-search LIS
+45 pts 40m
Data Structures & Algorithms hard

Topological sort (Kahn)

Return a valid topological ordering of tasks, or [] if a cycle exists.

graph BFS topological-sort
+45 pts 40m
Data Structures & Algorithms hard

Word ladder length

Return the length of the shortest transformation from beginWord to endWord changing one letter at a time.

BFS graph strings
+45 pts 40m
Advanced Python medium

Context manager timer

Implement a Timer context manager that records elapsed seconds.

context-manager time
+22 pts 20m
Advanced Python easy

Infinite counter generator

Create an infinite counter starting from `start`, stepping by `step`.

generators itertools
+12 pts 12m
Advanced Python medium

Retry decorator

Implement @retry(times=3) that retries a function on exception.

decorators error-handling
+28 pts 25m
Advanced Python medium

2D Vector dataclass

Implement a Vector2D dataclass with +, -, scalar *, dot product, and magnitude.

dataclass OOP math
+20 pts 18m
Advanced Python hard

Data pipeline

Implement a Pipeline class supporting pipe chaining with the | operator.

functional OOP pipeline
+40 pts 35m
Advanced Python hard

Validated descriptor

Implement a TypedField descriptor that raises TypeError if the value is not of the expected type.

descriptors OOP metaclass
+40 pts 35m

Showing 56 challenges