Python ยท Real Python

Python Coding Challenges: Practice Questions

100 questions. Try each one yourself before checking the answer.

Short on time? Filter by Must Do for the 25 questions that cover this topic on their own.

Q1Warm-upEasyMust Do

FizzBuzz โ€” and then make it extensible.

Q2StringsEasy

Reverse a string, and reverse the words in a sentence.

Q3StringsEasy

Check for a palindrome, with and without cleaning the input.

Q4ArraysEasyMust Do

Two Sum โ€” the canonical interview warm-up.

Q5ArraysEasy

Find the missing number, and then the duplicate.

Q6ArraysEasy

Move zeros, remove duplicates, and rotate โ€” all in place.

Q7DictionariesEasyMust Do

Count, group and find the most frequent.

Q8SetsEasy

Solve problems with set algebra instead of loops.

Q9RecursionEasy

Recursive problems, with the iterative version beside each.

Q10NumbersEasy

Classic number problems, done efficiently.

Q11StacksEasy

Bracket matching and expression evaluation.

Q12Two PointersEasyMust Do

Container with most water, and the merge of two sorted lists.

Q13Sliding WindowEasy

Longest substring without repeats, and the best fixed window.

Q14MatricesEasy

Rotate, transpose and spiral a grid.

Q15SortingEasyMust Do

Sort by several fields, and sort things that are not obviously sortable.

Q16SearchingEasyMust Do

Binary search and its three most common variants.

Q17Linked StructuresEasy

Build a linked list and solve the classic questions on it.

Q18TreesEasy

Build a binary tree and traverse it four ways.

Q19GraphsEasy

Represent a graph and answer the standard questions.

Q20Dynamic ProgrammingEasyMust Do

The four DP problems that appear most often.

Q21DesignEasy

Design small data structures with the required complexity.

Q22FilesEasy

Read, parse and summarise a file safely.

Q23RegexEasy

Extract and validate with regular expressions.

Q24ClassesEasy

Design a small class properly.

Q25Putting It TogetherEasyMust Do

Solve one problem five ways and choose between them.

Q26StringsMediumMust Do

Compress a string, and know when compression makes it longer.

Q27StringsMedium

Anagrams, isomorphic strings and one-edit distance.

Q28StringsMedium

Parse and normalise messy human input.

Q29ArraysMedium

Maximum subarray, and its three variations.

Q30ArraysMediumMust Do

Product except self, and prefix sums.

Q31DictionariesMedium

Invert, merge and nest dictionaries safely.

Q32DictionariesMedium

Build an index and answer queries against it.

Q33SortingMediumMust Do

Merge intervals, and the family of problems around it.

Q34Two PointersMedium

Three Sum, and the general k-sum shape.

Q35Sliding WindowMedium

Minimum window substring, and anagram windows.

Q36MatricesMedium

Flood fill, islands and the grid-BFS template.

Q37RecursionMedium

Backtracking: generate, prune, and undo.

Q38Dynamic ProgrammingMediumMust Do

Knapsack, and the difference between the two versions.

Q39Dynamic ProgrammingMedium

Grid paths, and how a constraint changes the recurrence.

Q40GraphsMedium

Dijkstra, and when BFS is enough.

Q41HeapsMedium

Top-k, merging streams, and the running median.

Q42ClassesMedium

Design a class hierarchy without over-engineering it.

Q43IteratorsMedium

Write generators that process data lazily.

Q44ErrorsMedium

Handle failure like production code.

Q45TestingMediumMust Do

Write the tests before the code.

Q46PerformanceMedium

Find the slow line before optimising anything.

Q47FilesMedium

Process a file too large to fit in memory.

Q48RegexMedium

Build a real log parser with named groups.

Q49ConcurrencyMedium

Speed up I/O-bound work with threads, and know why it fails for CPU work.

Q50Interview MethodMediumMust Do

The method: how to attack a problem you have never seen.

Q51Text AnalysisMediumMust Do

Build a word frequency analyser that survives real text.

Q52Data ValidationMedium

Validate a record against a schema and collect every error.

Q53CSV AnalysisMedium

Load a CSV, clean it, and answer questions about it.

Q54SudokuMedium

Validate a Sudoku board, then solve one.

Q55Password SecurityMediumMust Do

Score a password, and hash it the way you actually should.

Q56InventoryMedium

Model stock movements so the numbers always reconcile.

Q57File OrganisationMedium

Sort a messy folder, safely and reversibly.

Q58CachingMedium

Add caching, and understand what it costs.

Q59Rate LimitingMedium

Implement the three common rate limiters.

Q60State MachinesMediumMust Do

Model a workflow as a state machine instead of a pile of flags.

Q61DiffingHard

Compare two versions of the same data.

Q62SchedulingHard

Schedule tasks with dependencies and limited resources.

Q63SerialisationHard

Move objects in and out of JSON without losing anything.

Q64DeduplicationHardMust Do

Find duplicates when "duplicate" is not obvious.

Q65Text ProcessingHard

Build a small template engine.

Q66Undo & HistoryHard

Implement undo and redo two different ways.

Q67PaginationHard

Page through results without skipping or repeating rows.

Q68Money & RoundingHardMust Do

Get the arithmetic right when it is money.

Q69ConfigurationHard

Layer configuration from several sources, with the right precedence.

Q70API DesignHard

Design an interface that is hard to misuse.

Q71DebuggingHardMust Do

This function passes its tests and is wrong. Find out why.

Q72Hidden CostsHard

Six innocent-looking lines that are secretly quadratic.

Q73Numeric CorrectnessHard

Comparisons, accumulation and precision, and how each one bites.

Q74AliasingHard

Track down a bug caused by two names for one object.

Q75Recursion LimitsHard

Convert deep recursion into iteration without changing the answer.

Q76Concurrency BugsHard

Find the race in code that looks thread-safe.

Q77MemoryHard

Find what is keeping objects alive.

Q78Sorting PitfallsHard

Every way a sort can be subtly wrong.

Q79Text EncodingHard

Debug an encoding problem end to end.

Q80Security ReviewHardMust Do

Review this script the way an attacker would.

Q81Code ReviewHard

Review a hundred lines and rank what you find.

Q82Data Structure ChoiceHard

The algorithm is right and the program is slow. Fix the container.

Q83ScaleHard

Code that is correct at n=100 and unusable at n=10,000,000.

Q84Time CorrectnessHard

Every date bug in one scheduling feature.

Q85RefactoringHardMust Do

Break a working monolith into testable pieces without changing behaviour.

Q86Mini-Project โ€” Word Frequency AnalyserMini-ProjectMust Do

Build a complete word frequency analyser with a command interface.

Q87Mini-Project โ€” Log ParserMini-Project

Build a log parser that finds problems, not just lines.

Q88Mini-Project โ€” SudokuMini-Project

Build a Sudoku toolkit: validate, solve, rate and generate.

Q89Mini-Project โ€” Password ManagerMini-Project

Build an encrypted password vault from standard-library parts.

Q90Mini-Project โ€” CSV AnalyserMini-ProjectMust Do

Build a general CSV analyser that profiles any file it is given.

Q91Mini-Project โ€” Inventory SystemMini-Project

Build an inventory system with orders, reservations and reporting.

Q92Mini-Project โ€” File OrganiserMini-Project

Build a file organiser with rules, deduplication and undo.

Q93Mini-Project โ€” Task SchedulerMini-Project

Build a recurring task scheduler with priorities and history.

Q94Mini-Project โ€” Expression InterpreterMini-Project

Build a tokeniser, parser and evaluator for a small language.

Q95Mini-Project โ€” Testing a SystemMini-Project

Test a whole system: unit, property, integration and edge cases.

Q96Mock InterviewInterview

A full 45-minute coding interview, transcribed.

Q97System DesignInterview

Design a URL shortener, out loud, in forty minutes.

Q98CommunicationInterview

Explain your reasoning: the sentences that earn the marks.

Q99Take-HomeInterview

Complete a take-home assignment the way a senior engineer would.

Q100CapstoneInterviewMust Do

The final question: build one program that uses everything.

Still stuck on something?

Book a free 1-on-1 session and we'll work through it together.

Book a Free Session