Practice Arena

Python Coding Challenges

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

925 challenges 556 easy 323 medium 46 hard
Python Basics easy

Swap Two Values

Implement a Python function that swaps two given values and returns them in swapped order.

variables assignment swap
+5 pts 5m
Python Basics easy

Is divisible by?

Create a function that returns True if a is divisible by b with no remainder, with a clear definition of edge cases.

division modulo conditionals
+10 pts 10m
Python Basics easy

Volume of Cube

Write a Python function that returns the volume of a cube given its side length.

arithmetic return function
+5 pts 5m
Python Basics easy

Enumerate with start

Implement a function that mimics Python's enumerate with a custom start index.

enumerate loops tuples
+5 pts 5m
Python Basics easy

Convolve 1D signal

Implement a 1D convolution function with three modes using pure Python.

convolution arrays loops
+8 pts 12m
Python Basics easy

Cosine Similarity of Vectors

Compute the cosine similarity between two equal-length numeric vectors using pure Python.

math linear-algebra similarity
+10 pts 15m
Strings & Text easy

Find all indexes of a substring

Write a function that returns a list of all starting indexes where a substring appears in a string, including overlapping occurrences.

substring string searching
+10 pts 15m
Strings & Text easy

Capitalize First Letter

Write a function that capitalizes the first letter of each word in a string.

string capitalization title
+8 pts 10m
Strings & Text easy

Parse key=value pairs

Implement a parser that converts a space-separated 'key=value' string into a Python dictionary, supporting quoted values.

parsing strings dictionaries
+8 pts 10m
Strings & Text easy

Parse Boolean Strings

Implement a function that parses a boolean string into a Python bool, handling True/False/Yes/No/1/0 case-insensitively.

strings boolean parsing
+10 pts 10m
OOP & Classes medium

Complex Number Class

Implement a Complex class supporting addition, subtraction, multiplication, division, equality, and string formatting.

classes magic-methods arithmetic
+20 pts 25m
OOP & Classes easy

Dataclass with slots

Implement a slotted frozen dataclass representing a 2D point with total ordering.

dataclass slots immutability
+10 pts 15m
Advanced Python medium

TypeVar bounded generic

Learn to use TypeVar with bounds to write type-safe generic functions in Python.

generics typevar typing
+20 pts 15m
Advanced Python medium

Descriptor Property

Create a descriptor class that ensures attribute values are positive integers.

descriptors oop python-advanced
+20 pts 20m
Iterators & Generators easy

Custom iterator class

Implement a custom iterator class that repeatedly yields elements from a list up to a given number of times.

iterator class cycle
+10 pts 15m
Iterators & Generators easy

Range-like generator

Implement a custom generator that yields numbers like Python's range but with flexible bounds.

generator yield range
+8 pts 12m
Iterators & Generators easy

File Line Reader Generator

Implement a generator function that reads a file-like object and yields each non-empty line without loading the whole file into memory.

generators file-io lazy-evaluation
+10 pts 15m
Decorators & Context Managers easy

File Open Context Manager

Create a class that acts as a context manager for opening a virtual file in memory.

context-manager file-io python
+10 pts 15m
Decorators & Context Managers easy

Timer Context Manager

Implement a context manager that measures execution time of a with block and stores it.

context-manager timing measurement
+10 pts 15m
Regular Expressions easy

Multiline anchor match

Extract lines beginning with a plain-text prefix from multiline strings using Python's re module.

regex anchors multiline
+10 pts 15m
Math & Number Theory medium

Correlation Coefficient

Write a pure-Python function that computes the Pearson correlation coefficient between two lists of numbers.

statistics math arrays
+15 pts 15m
Binary Search medium

Interpolation Search

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

search sorted-array binary-search
+25 pts 25m
Data Formats & Parsing medium

Serialize dict to TOML-like

Convert nested Python dicts into a simplified TOML-like string with sorted keys, type-aware formatting, and flat table sections.

dict toml serialization
+20 pts 25m
SQL & SQLite medium

Nth Highest Salary

Write a Python function using SQLite to return the Nth highest distinct salary from an employee table.

sql sqlite aggregation
+20 pts 20m

Showing 1–24 of 24 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.