Practice · 32 challenges · 4 levels
Python Challenges
Solve real problems with Python, right in your browser. Every challenge has worked examples, hidden tests, step-by-step hints and an explained solution. No sign-up: your progress is saved in this browser.
Start with the first challenge0 / 32
challenges solved
Very easy· 8
- 01Add Two NumbersWrite your first function: take two numbers and return their sum.functionsmath
- 02Even or OddReturn True when a whole number is even and False when it is odd.conditionsmath
- 03Celsius to FahrenheitConvert a temperature from Celsius to Fahrenheit with a formula.mathfloats
- 04Say HelloBuild a greeting string from a name.stringsf-strings
- 05Last ItemReturn the last element of a list, or None when the list is empty.listsindexing
- 06Biggest of ThreeReturn the largest of three numbers.conditionsfunctions
- 07Reverse a StringReturn a string written backwards.stringsslicing
- 08Sum a ListAdd up every number in a list using a loop.listsloops
Easy· 8
- 09Count the VowelsCount how many vowels appear in a piece of text.stringsloops
- 10FizzBuzzThe classic: Fizz for 3s, Buzz for 5s, FizzBuzz for both.loopsconditions
- 11FactorialMultiply all the whole numbers from 1 up to n.loopsmath
- 12Palindrome CheckDecide whether a phrase reads the same forwards and backwards.strings
- 13Remove DuplicatesDrop repeated items from a list while keeping the original order.listssets
- 14Sum of DigitsAdd up the digits of a whole number.mathloops
- 15Capitalize Every WordTurn the first letter of every word into a capital letter.stringslists
- 16Fibonacci NumberReturn the nth number of the Fibonacci sequence.loopsmath
Medium· 8
- 17Word FrequencyCount how many times each word appears in a text.dictionariesstrings
- 18Anagram CheckDecide whether two phrases use exactly the same letters.stringssorting
- 19Two SumFind the positions of two numbers that add up to a target.dictionarieslists
- 20Flatten a Nested ListTurn a list of lists of lists… into one flat list.recursionlists
- 21Run-Length EncodingCompress repeated letters: aaabcc becomes a3b1c2.stringsloops
- 22Second LargestFind the second largest distinct number in a list.listssets
- 23Balanced BracketsCheck that every bracket is closed in the right order.stacksstrings
- 24Roman Numerals to IntegerConvert a Roman numeral like MCMXCIV into a number.dictionariesstrings
Hard· 8
- 25Longest Substring Without RepeatsFind the length of the longest stretch of text with no repeated character.sliding windowdictionaries
- 26Merge IntervalsCombine overlapping time ranges into as few ranges as possible.sortinglists
- 27Spiral MatrixRead a grid of numbers in clockwise spiral order.2D listsloops
- 28Edit DistanceCount the fewest single-letter edits that turn one word into another.dynamic programmingstrings
- 29All PermutationsList every distinct rearrangement of the letters in a word.recursionbacktracking
- 30Count the IslandsCount separate groups of land on a grid map.graphsrecursion
- 31Evaluate an ExpressionBuild a tiny calculator that respects brackets and operator precedence.parsingrecursion
- 32Coin ChangeFind the fewest coins that add up to an amount.dynamic programming
New to Python? Start with the free course, or watch your code run line by line in the Python visualizer.