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

Collatz steps

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

loops math
1
+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 easy

Prime checker

Return True if n is a prime number.

math loops
1
+10 pts 10m
Python Basics easy

Compound interest

Return the future balance after compound interest, rounded to two decimals.

math functions finance
+12 pts 12m
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

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

Circle Circumference Calculator

Implement a function that computes the circumference of a circle from its radius using the formula 2πr.

math function basics
+10 pts 10m
Python Basics easy

Digit Count

Count the number of digits in an integer using arithmetic, without string conversion.

numbers loops math
+8 pts 12m
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

Hexagonal Number

Write a function to check if a positive integer is a hexagonal number.

math loops conditionals
+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
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

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 easy

Difference of Consecutive Elements

Given a list of numbers, return a new list where each element is the difference between consecutive elements.

list iteration math
+8 pts 10m
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
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
Advanced Python medium

2D Vector dataclass

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

dataclass OOP math
1
+20 pts 18m
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

Clamp and round to nearest ten

Clamp a number between given bounds and round the result to the nearest ten with halves away from zero.

clamping rounding math
+10 pts 12m
Math & Number Theory easy

Integer Square Root Floor

Implement a function that returns the greatest integer whose square is ≤ n, using only integer operations.

math binary-search integer
+8 pts 12m
Math & Number Theory easy

Power set size

Compute the size of the power set of a given sequence.

math subsets counting
+8 pts 10m
Math & Number Theory easy

Polynomial evaluator

Implement a polynomial evaluator that computes the value of a polynomial given as a list of coefficients.

polynomial math evaluation
+5 pts 10m
Math & Number Theory easy

Catalan number

Implement a function that returns the nth Catalan number using dynamic programming.

math dynamic-programming combinatorics
+10 pts 15m
Math & Number Theory easy

Stirling number

Implement a function to compute Stirling numbers of the second kind S(n,k).

stirling-numbers dynamic-programming combinatorics
+10 pts 15m
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

Prime Factorization

Return a sorted list of prime factors of a positive integer, including repeated factors.

prime math loops
+10 pts 15m
Math & Number Theory easy

Count divisors

Compute the number of positive divisors of a given integer using its prime factorization.

divisors prime factorization math
+10 pts 15m
Math & Number Theory easy

Sum of divisors

Given an integer n, return the sum of all its positive divisors.

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

Perfect Number Check

Write a function that returns True if a number is perfect, i.e., equal to the sum of its proper divisors.

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

Abundant Number Check

Implement a function to check whether a given integer is abundant: sum of proper divisors exceeds the number.

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

Amicable Numbers Check

Write a function that checks if two numbers are an amicable pair by comparing sums of proper divisors.

divisors arithmetic math
+10 pts 15m
Math & Number Theory easy

Happy number check

Implement a function that returns True if a number is happy, False otherwise.

math loops set
+8 pts 12m
Math & Number Theory easy

Harshad Number Check

Write a function that checks if a number is a Harshad (or Niven) number.

math digits divisibility
+8 pts 10m
Math & Number Theory easy

Triangular Number

Implement a function that returns the nth triangular number using the closed-form formula.

triangular formula math
+10 pts 10m
Math & Number Theory easy

Pentagonal Number

Given a positive integer n, return the nth pentagonal number using the formula P(n) = n(3n - 1)/2.

math formula integer
+10 pts 10m
Math & Number Theory easy

Lucas Sequence

Implement a function to compute the n-th Lucas number using iteration or recursion with memoization.

math sequence dynamic programming
+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
Bit Manipulation easy

Missing Number XOR

Given a list of n distinct numbers from 0 to n with one missing, use XOR to find and return the missing number.

xor bitwise arrays
+10 pts 15m
Dynamic Programming medium

Bell number

Implement a function to compute the Bell number B(n) using dynamic programming.

dp combinatorics math
+25 pts 25m
Dynamic Programming medium

Perfect Squares Sum

Given a positive integer n, return the least number of perfect squares (e.g., 1, 4, 9, 16, ...) that sum to n.

dynamic-programming math optimization
+25 pts 25m
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
Datetime & Time Calculations easy

Days in month

Write a function that returns the number of days in a given month and year, correctly handling leap years.

datetime calendar leap-year
+8 pts 10m

Showing 45 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.