FizzBuzz, precisely
Return a newline-separated string for 1..n: Fizz, Buzz, FizzBuzz, or the number.
Prime checker
Return True if n is a prime number.
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.
Sum numbers from 1 to n
Implement a function that computes the sum of all integers from 1 to n.
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.
Digit count of an integer
Given an integer, return the number of digits it has, handling negatives and zero correctly.
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.
Replace negatives with zero
Implement a function that replaces all negative numbers in a list with zero.
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!'.
Average of a list
Write a function that computes the average of a list of numbers, handling empty lists by returning 0.
Count Positives
Count the positive numbers in a list of integers.
Range of values
Calculate the range (max minus min) of a list of numbers. Empty list returns 0.
Area of Rectangle
Write a function that returns the area of a rectangle given its width and height.
Digit Count
Count the number of digits in an integer using arithmetic, without string conversion.
Find Missing Number
Given a list of n distinct integers from 0..n with one missing, return the missing number.
Variadic Sum Function
Implement a variadic function that sums an arbitrary number of numeric arguments.
Palindromic Number Check
Write a function to check if a given integer is a palindrome.
Hexagonal Number
Write a function to check if a positive integer is a hexagonal number.
Count trailing zeros
Write a function that counts the number of trailing zeros in the decimal representation of a positive integer.
Count Leading Zeros
Write a function that returns the number of leading zeros in a list of integers.
Guess Number Game
Simulate a number guessing game with attempts, feedback, and a win/lose result.
Parse environment variables
Write parse_env_vars that parses KEY=VALUE lines into a dict, converting booleans/numbers and ignoring comments.
Array mean and std
Implement the function array_stats that returns the mean and population standard deviation of a list of numbers.
Broadcast Add Scalar
Add a scalar to every number in a 2D list and return a new 2D list without modifying the original.
Cumulative Sum Vectorized
Implement a function that returns the cumulative sum of a list of numbers.
Percentile Calculation
Given a list of numbers and a target value, return the percentile rank of that value in the list.
Count vowels
Count the number of vowels (a, e, i, o, u) in a string (case-insensitive).
Camel case to snake case
Write a function that converts camelCase input to snake_case while handling acronyms and numbers correctly.
Count consonants
Write a function that counts the number of consonant letters in a string.
Rotate String Right
Implement a function that rotates a given string to the right by a specified number of positions, handling shifts larger than the string length.
Find all numbers in text
Write a function that extracts all standalone integers from a text string using regular expressions.
Caesar Cipher Decrypt
Implement a function that decrypts a Caesar cipher by shifting letters back by a given number.
Parse numbered list
Take a string containing a numbered list and return a clean list of the item texts.
Parse range notation
Parse a comma-separated list of ranges and individual numbers, expanding each range into its full sequence.
Move Zeros to the End
Reorder a list in-place, pushing all zeros to the end while preserving the order of non-zero numbers.
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.
Difference of Consecutive Elements
Given a list of numbers, return a new list where each element is the difference between consecutive elements.
Find Second Largest
Find the second largest unique number in a list, or None if it doesn't exist.
Rearrange Positives and Negatives
Write a function that rearranges a list in-place so all negative numbers come before non-negative numbers.
Convert Binary Number List
Given a list of bits (0s and 1s) in most-significant-first order, return the equivalent integer value.
Intersection two lists length
Return the number of distinct elements that appear in both input lists.
Normalize Array to Zero-One Range
Implement a function that normalizes a list of numbers to the range [0,1] using min-max scaling.
Rolling Window Mean
Given a list of numbers and a window size k, return a list of the means of every contiguous subarray of length k.
Union of Many Sets
Implement a function that takes any number of sets and returns a sorted list of their union.
Values that appear once
Return a list of numbers that appear exactly once in the input list, in original order.
Two Sum with Dict
Implement the classic Two Sum problem: return indices of two numbers that add up to a target using a dict.
Count Pairs with Sum
Implement a function that counts the number of distinct pairs in a list summing to a target.
Employee Hierarchy
Build an employee hierarchy tree and compute the total number of direct and indirect reports for each employee.
Bubble Sort
Implement bubble sort that sorts a list of numbers in ascending order.
Selection Sort Implementation
Implement selection sort to sort a list of numbers in ascending order.
Custom iterator class
Implement a custom iterator class that repeatedly yields elements from a list up to a given number of times.
Generator Pipeline
Implement a generator function that yields only even numbers from an input list, squared.
Range-like generator
Implement a custom generator that yields numbers like Python's range but with flexible bounds.
Fibonacci Generator
Create a generator function that yields Fibonacci numbers from 0 upward until a given limit.
Iterator protocol class
Implement a class that follows the iterator protocol and yields squared numbers up to a given limit.
Divide with zero check
Write a function that safely divides two numbers, catching division by zero.
Else on try block
Implement a function that uses try-except-else to safely divide two numbers and return a result or error description.
Validate phone number
Write a function that uses regular expressions to determine if a given string is a valid US phone number.
Nth Triangular Number
Implement a function that returns the nth triangular number efficiently.
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.
Catalan number
Implement a function that returns the nth Catalan number using dynamic programming.
Stirling number
Implement a function to compute Stirling numbers of the second kind S(n,k).
Euler Totient Function
Implement Euler's totient function φ(n) for positive integers.
Prime Factorization
Return a sorted list of prime factors of a positive integer, including repeated factors.
Count divisors
Compute the number of positive divisors of a given integer using its prime factorization.
Sum of divisors
Given an integer n, return the sum of all its positive divisors.
Perfect Number Check
Write a function that returns True if a number is perfect, i.e., equal to the sum of its proper divisors.
Abundant Number Check
Implement a function to check whether a given integer is abundant: sum of proper divisors exceeds the number.
Amicable Numbers Check
Write a function that checks if two numbers are an amicable pair by comparing sums of proper divisors.
Armstrong Number Check
Implement a function that checks if a given integer is an Armstrong number.
Happy number check
Implement a function that returns True if a number is happy, False otherwise.
Harshad Number Check
Write a function that checks if a number is a Harshad (or Niven) number.
Triangular Number
Implement a function that returns the nth triangular number using the closed-form formula.
Pentagonal Number
Given a positive integer n, return the nth pentagonal number using the formula P(n) = n(3n - 1)/2.
Lucas Sequence
Implement a function to compute the n-th Lucas number using iteration or recursion with memoization.
Partition function
Write a function that returns the number of ways to write a positive integer as a sum of positive integers (order irrelevant).
Deficient Number Check
Write is_deficient(n) that returns True if the sum of proper divisors is less than n.
Kaprekar number check
Check whether a given non-negative integer is a Kaprekar number in base 10.
Stars and Bars Count
Implement stars_and_bars_count(n, k) which returns the number of ways to put n identical items into k distinct bins, with bins allowed to be empty.
Z score normalization
Compute the z-scores for a list of numbers using the population standard deviation.
Count Set Bits
Implement a function that returns the number of set bits (1s) in the binary representation of a non-negative integer.
Single Number XOR
Given a non-empty list of integers where every element appears twice except one, return the single number using XOR.
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.
Isolate Rightmost Set Bit
Given an integer, return a number with only its rightmost set bit set.
Rotate Bits Left
Implement a function that rotates the bits of an integer to the left by a specified number of positions.
Sparse Number Check
Check if a non-negative integer is sparse, meaning its binary representation contains no adjacent 1 bits.
Odd Parity Bit
Given an integer, return the odd parity bit (0 or 1) so that total number of 1-bits in the 8-bit representation becomes odd.
Climbing Stairs
Implement a function that returns the number of distinct ways to climb n stairs using steps of 1 or 2.
Unique Paths in a Grid
Count the number of unique paths from the top-left corner to the bottom-right corner of a grid, moving only right and down.
Assign Cookies
Given child greed factors and cookie sizes, return the maximum number of content children.
Maximum Ice Cream Bars
Given costs of ice cream bars and coins, return the maximum number you can buy.
Reduce array to zero
Given an array of non-negative integers, each operation chooses two indices and subtracts 1 from each if both are positive. Return the minimum number of operations to reduce the array to all zeros, or -1 if impossible.
Days in month
Write a function that returns the number of days in a given month and year, correctly handling leap years.
Days Between Dates
Write a function that returns the number of days between two given dates.
Add Days to Date
Given a date in YYYY-MM-DD format and an integer number of days, return the resulting date in the same format.
Business days between
Calculate the number of business days (Mon-Fri) between two dates, inclusive of both endpoints.
Week Number ISO
Given a date, return its ISO 8601 week number (1–53) without using datetime.isocalendar().
Duration Human Readable
Write a function that turns a number of seconds into a human-readable duration like '2 hours, 1 minute'.
Showing 104 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.