Practice Arena

Python Coding Challenges

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

467 challenges 330 easy 120 medium 17 hard
Python Basics easy

GCD via Euclid

Compute the greatest common divisor of two positive integers.

math recursion
+10 pts 10m
Python Basics easy

Absolute Difference of Two Integers

Compute the absolute difference between two integers, regardless of order.

absolute difference math
+5 pts 5m
Python Basics easy

Grade from Score

Write a function that maps a numeric score to its letter grade using standard grading thresholds.

conditionals functions integers
+8 pts 10m
Python Basics easy

Min of three numbers

Write a function that returns the minimum of three integers.

min comparison function
+5 pts 5m
Python Basics easy

Integer division and remainder

Write a function that performs integer division and returns both quotient and remainder.

operators division remainder
+8 pts 10m
Python Basics easy

Sum numbers from 1 to n

Implement a function that computes the sum of all integers from 1 to n.

sum loop arithmetic
+5 pts 5m
Python Basics easy

Seconds to Hours Minutes Seconds

Convert total seconds into a zero-padded HH:MM:SS format.

arithmetic divmod formatting
+8 pts 10m
Python Basics easy

Digit count of an integer

Given an integer, return the number of digits it has, handling negatives and zero correctly.

integers loops arithmetic
+5 pts 5m
Python Basics easy

Count Multiples in a Range

Given a start, end, and divisor, count how many integers in [start, end] are divisible by the divisor.

multiples range divisibility
+10 pts 10m
Python Basics easy

Sum from 1 to n

Write a function that returns the sum of all integers from 1 to n (inclusive).

math arithmetic sum
+5 pts 5m
Python Basics easy

Count Positives

Count the positive numbers in a list of integers.

conditionals loops basic
+10 pts 10m
Python Basics easy

Round to nearest ten

Write a function that rounds any integer to the nearest multiple of ten.

arithmetic rounding integers
+8 pts 10m
Python Basics easy

Modulo Remainder

Implement a function that returns the remainder of a divided by b without using the modulo operator.

modulo arithmetic integers
+5 pts 5m
Python Basics easy

Last Digit Extractor

Write a function that returns the last digit of a non-negative integer using the modulo operator.

integers modulo arithmetic
+5 pts 5m
Python Basics easy

Find Missing Number

Given a list of n distinct integers from 0..n with one missing, return the missing number.

math integers arrays
+10 pts 10m
Python Basics easy

Map, Filter, Reduce

Implement three functions using map, filter, and reduce to manipulate a list of integers.

map filter reduce
+10 pts 15m
Python Basics easy

Count trailing zeros

Write a function that counts the number of trailing zeros in the decimal representation of a positive integer.

loops integers basics
+5 pts 5m
Python Basics easy

Count Leading Zeros

Write a function that returns the number of leading zeros in a list of integers.

lists iteration counting
+8 pts 8m
Strings & Text easy

Find all numbers in text

Write a function that extracts all standalone integers from a text string using regular expressions.

regex parsing numbers
+8 pts 12m
Lists & Arrays easy

Running Product of Integers

Given a list of integers, return a new list where each element at index i is the product of all elements from index 0 to i.

prefix product lists
+10 pts 10m
Lists & Arrays easy

Find Missing Number 1 to n

Given a list containing n-1 distinct integers from 1 to n, find the missing number without using extra space.

arrays math search
+10 pts 10m
Lists & Arrays medium

Product of All Except Zeros Handling

Given a list of integers, return a list where each element is the product of all other elements, handling zeros correctly.

product arrays zero-handling
+20 pts 25m
Lists & Arrays medium

Find Duplicate Number

Given a list of n+1 integers in the range 1..n, find the one integer that appears more than once.

arrays hash-set duplicates
+20 pts 25m
Lists & Arrays easy

Wave sort array

Given a list of integers, reorder it into a wave pattern where elements alternate down-up, and return the new list.

sorting swap rearrangement
+10 pts 15m
Lists & Arrays easy

Counting Sort

Implement the counting sort algorithm to sort a list of non-negative integers in O(n + k) time.

sorting counting arrays
+10 pts 15m
Lists & Arrays medium

Two Missing Numbers

Given a list of n-2 unique integers from 1 to n, find the two missing numbers efficiently.

missing-numbers arrays math
+25 pts 25m
Lists & Arrays medium

Three Missing Numbers

Find the three missing numbers from a shuffled list containing all but three integers from 1 to n.

arrays sets missing
+15 pts 15m
Dicts & Sets easy

Keys Sorted by Value Descending

Given a dictionary mapping strings to integers, return a list of keys sorted by value descending, and when values tie, alphabetically ascending.

sorting dictionaries ordering
+8 pts 10m
Data Structures & Algorithms medium

Longest Consecutive Sequence

Given an unsorted list of integers, find the length of the longest consecutive elements sequence in O(n) time.

hash set array linear
+20 pts 20m
Data Structures & Algorithms easy

Pascal Triangle Row

Given a non-negative integer n, return the nth row of Pascal's triangle as a list of integers.

math combinatorics arrays
+10 pts 15m
Data Structures & Algorithms medium

Radix Sort

Implement LSD radix sort to sort a list of non-negative integers in ascending order.

radix-sort sorting counting-sort
+25 pts 25m
Iterators & Generators easy

Digit Expansion Generator

Create a generator that lazily yields each decimal digit of a non-negative integer from most significant to least significant.

generators yield digits
+8 pts 10m
Math & Number Theory easy

Nth Triangular Number

Implement a function that returns the nth triangular number efficiently.

math formula integers
1
+10 pts 10m
Math & Number Theory easy

Euler Totient Function

Implement Euler's totient function φ(n) for positive integers.

math number-theory totient
+10 pts 15m
Math & Number Theory easy

Partition function

Write a function that returns the number of ways to write a positive integer as a sum of positive integers (order irrelevant).

math recursion memoization
+12 pts 15m
Math & Number Theory easy

Multiply without multiply

Write a function that multiplies two integers using only addition, subtraction, and bit shifts — no * operator.

multiplication bit-manipulation arithmetic
+8 pts 12m
Bit Manipulation easy

Single Number XOR

Given a non-empty list of integers where every element appears twice except one, return the single number using XOR.

xor bit-manipulation arrays
+10 pts 12m
Bit Manipulation easy

Gray Code Decode

Implement gray_decode(n) that converts an n-bit Gray code integer back to its standard binary value using XOR accumulation.

gray-code bit-manipulation xor
+10 pts 15m
Bit Manipulation medium

Bitwise AND of a Range

Given a range [a, b], return the bitwise AND of all integers in that inclusive range without iterating over all numbers.

bitwise range optimization
+20 pts 15m
Bit Manipulation easy

Add without plus

Implement a function that adds two integers using only bitwise operations, no arithmetic plus or minus.

bitwise addition xor
+10 pts 15m
Bit Manipulation medium

Divide using shifts

Implement division of two integers using only bit shifts and arithmetic, without using division or modulo operators.

integer division bit shifts overflow
+20 pts 20m
Bit Manipulation easy

Brian Kernighan count

Implement a function that counts set bits using Brian Kernighan's efficient algorithm.

bit-manipulation integers counting
+10 pts 15m
Dynamic Programming medium

Partition Equal Subset

Determine whether a given list of positive integers can be partitioned into two subsets with equal sum.

dynamic-programming subset-sum memoization
+30 pts 25m
Dynamic Programming medium

Target Sum Subsets

Write a function that counts the number of subsets of a list of positive integers that sum exactly to a target.

subset-sum dp counting
+25 pts 30m
Dynamic Programming medium

Integer Break Product

Given a positive integer n, break it into at least two positive integers that sum to n and maximize their product.

integer-break dynamic-programming max-product
+25 pts 30m
Dynamic Programming medium

Longest Arithmetic Subsequence

Given a list of integers, return the length of the longest arithmetic subsequence (constant difference) within it.

dp subsequence hashmap
+30 pts 25m
Recursion & Backtracking easy

Permutation Generator

Write a function that returns all permutations of a list of distinct integers.

recursion backtracking permutations
+10 pts 15m
Recursion & Backtracking medium

Combination Generator

Write a recursive function that returns all combinations of length k from a list of distinct integers.

recursion backtracking combinations
+25 pts 25m
Binary Search medium

Interpolation Search

Implement interpolation search in Python on a sorted list of integers.

search sorted-array binary-search
+25 pts 25m
Two Pointers & Sliding Window hard

Trapping Rain Water

Given an array of non-negative integers representing an elevation map, compute how much water it can trap after raining.

array two-pointers water-trapping
+40 pts 30m
Two Pointers & Sliding Window medium

Count Nice Subarrays

Given an array of integers, count the number of contiguous subarrays that contain exactly k odd numbers.

sliding-window two-pointers subarray
+25 pts 25m
Two Pointers & Sliding Window hard

Subarrays with K different ints

Count the number of contiguous subarrays that contain exactly K distinct integers.

sliding-window two-pointers hashmap
+40 pts 40m

Showing 52 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

  1. Pick a category — basics, algorithms, strings, and more
  2. Open a challenge, read the statement, and edit the starter code
  3. 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.