Clamp a Number to a Range
Implement a clamp function that returns a value within a specified range.
Min of three numbers
Write a function that returns the minimum of three integers.
Integer division and remainder
Write a function that performs integer division and returns both quotient and remainder.
Count down from n
Implement a function that returns a list from n down to 1.
Sign of a Number
Write a function that returns the sign of a number as a string.
Is a multiple of both
Write a function that returns True if a number is divisible by both of two given divisors.
Boolean from comparison chain
Implement a function that evaluates a chain of comparisons and returns the boolean result.
Max of a variable-length list
Implement a function that returns the maximum value from a list of numbers without using max().
Between inclusive
Write a function that returns True if a number is between two given bounds, inclusive of the bounds.
Last Occurrence of a Value
Implement a function that returns the last index of a given value in a list, or -1 if it's not present.
Boolean Mask Filter
Write a function that filters a list based on a boolean mask and returns the selected elements.
Set symmetric difference
Write a function that returns the elements found in exactly one of two sets, sorted ascending.
Swap Two Values
Implement a Python function that swaps two given values and returns them in swapped order.
Hello, name!
Implement a function that returns a personalized greeting for a given name.
Leap Year Checker
Implement a function that returns True if a year is a leap year according to the Gregorian calendar rules.
Absolute Difference
Implement a function that returns the absolute difference between two numbers.
Max of three numbers
Implement a function that returns the maximum of three numbers using comparisons.
Sign of a number
Write a function sign_of_number that returns -1 for negatives, 0 for zero, and 1 for positives.
Countdown printer
Implement a function that prints a countdown from a given number down to 1, then returns 'Go!'.
Sum from 1 to n
Write a function that returns the sum of all integers from 1 to n (inclusive).
Find Minimum Value
Write a function that returns the minimum integer from a given list.
Range of values
Calculate the range (max minus min) of a list of numbers. Empty list returns 0.
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.
Area of Rectangle
Write a function that returns the area of a rectangle given its width and height.
Volume of Cube
Write a Python function that returns the volume of a cube given its side length.
Modulo Remainder
Implement a function that returns the remainder of a divided by b without using the modulo operator.
Print Pyramid Pattern
Implement a function that returns a centered asterisk pyramid as a list of strings.
Last Digit Extractor
Write a function that returns the last digit of a non-negative integer using the modulo operator.
Count word occurrences
Write a function that takes a sentence and returns a dictionary of word counts.
Linear Search Implementation
Implement a linear search function that returns the index of the first occurrence of a target in a list, or -1 if not found.
Count Leading Zeros
Write a function that returns the number of leading zeros in a list of integers.
Longest word in a sentence
Write a function that returns the longest word from a sentence, with first-occurrence tie-breaking.
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.
Longest Word Finder
Write a function that extracts alphabetic words from a string and returns the longest one, with ties broken by earliest position.
Abbreviate Name
Create a function that takes a full name and returns an abbreviated version with initials and the last name.
Find substring index
Implement a function that returns the starting index of the first occurrence of a substring using only basic string indexing and slicing.
Sort characters in string
Write a function that sorts the characters in a string and returns the sorted string.
Safe Command Executor
Implement emulate_run that simulates running a command list and returns output and exit code.
Parse Log Line
Write a function that parses a log line and returns a dictionary with timestamp, level, and message.
Validate username format
Implement a function that validates a username according to length, allowed characters, and no consecutive underscores.
Running Maximum
Implement a function that returns a list where each element is the largest value seen so far.
Zip lists into pairs
Write a function that takes two lists and returns a list of two-element sublists pairing elements by index up to the shortest length.
Middle Element of an Odd-Length List
Implement a function that returns the middle element of an odd-length list.
Is Subset of Another List
Write a function that returns True if every element in a given list exists in another list, ignoring duplicates.
Unzip pairs into two lists
Write a function that takes a list of pairs and returns two separate lists: first elements and second elements.
Generate a Multiplication Table
Build a function that returns an n x n multiplication table as a list of lists.
Majority Element Finder
Implement a function that returns the majority element in a list, which appears more than half the time.
Union of Two Lists
Implement a function that combines two lists and returns only unique elements.
Difference of Two Lists
Write a function that returns items in list a that are not in list b, preserving order and duplicates.
Last occurrence index
Implement a function that returns the last index of a given value in a list, or -1 if the value is not present.
Word to Index Map
Create a function that returns a dictionary mapping each unique word to the index of its first occurrence.
Common Keys of Two Dictionaries
Implement a function that finds keys shared by two dictionaries and returns them sorted.
Union of Many Sets
Implement a function that takes any number of sets and returns a sorted list of their union.
Mode of a list via counting
Implement a function that returns the mode of a list, resolving ties by the element that appears first.
Index of peak element
Implement a function that returns the index of any peak element in a given integer array.
Once Decorator: Run a Function Only Once
Implement a decorator that caches and returns the result of the first call for subsequent calls.
Print Args Decorator
Write a decorator that prints function name and arguments, then returns the original result.
Safe divide function
Implement safe_divide that returns None on ZeroDivisionError and TypeError.
Key error handler
Implement a safe dictionary access function that returns a default value on missing keys.
Nth Triangular Number
Implement a function that returns the nth triangular number efficiently.
Integer Square Root Floor
Implement a function that returns the greatest integer whose square is ≤ n, using only integer operations.
Catalan number
Implement a function that returns the nth Catalan number using dynamic programming.
Perfect Number Check
Write a function that returns True if a number is perfect, i.e., equal to the sum of its proper divisors.
Happy number check
Implement a function that returns True if a number is happy, False otherwise.
Triangular Number
Implement a function that returns the nth triangular number using the closed-form formula.
Partition function
Write a function that returns the number of ways to write a positive integer as a sum of positive integers (order irrelevant).
Count Set Bits
Implement a function that returns the number of set bits (1s) in the binary representation of a non-negative integer.
Check Power of Two Bits
Implement is_power_of_two(n) that returns True if n is a power of two and False otherwise.
Find Rightmost Set Bit
Implement a function that returns the 1-indexed position of the rightmost set bit of a positive integer, or 0 if none.
Set kth Bit
Implement a function that sets the kth bit (0-indexed) of a non-negative integer to 1 and returns the result.
Climbing Stairs
Implement a function that returns the number of distinct ways to climb n stairs using steps of 1 or 2.
Binary Tree Inorder Traversal
Implement an inorder traversal function that returns node values in left-root-right order.
Preorder Traversal
Implement a function that returns the preorder traversal values of a binary tree.
Postorder Traversal
Implement a function that returns the postorder traversal of a binary tree as a list of node values.
Permutation Generator
Write a function that returns all permutations of a list of distinct integers.
Longest Substring Without Repeating Characters
Implement a function that returns the length of the longest substring without repeating characters.
Days in month
Write a function that returns the number of days in a given month and year, correctly handling leap years.
Showing 77 challenges · easy
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
- Pick a category — basics, algorithms, strings, and more
- Open a challenge, read the statement, and edit the starter code
- 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.