Python ยท Real Python

Mini Problem Solving: 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.

Q1Modelling a RecordEasyMust Do

Model one student as a dictionary, with validation in a single place.

Q2Modelling with a ClassEasy

Model the same record as a class, and see what that buys.

Q3MoneyEasy

Handle money without losing paise to floating point.

Q4GradingEasyMust Do

Turn marks into a grade, a percentage and a verdict.

Q5Safe ConversionEasy

Convert user text into numbers without crashing.

Q6Lookup TablesEasy

Replace a chain of if statements with a dictionary.

Q7CountingEasy

Count occurrences and report the leaders.

Q8GroupingEasy

Group records by a field.

Q9Sorting RecordsEasyMust Do

Sort records by one field, then by several.

Q10SearchingEasy

Find records that match, and handle "not found" properly.

Q11FilteringEasy

Combine filters without writing one function per combination.

Q12AggregatingEasy

Summarise a set of records.

Q13Formatting a ReportEasyMust Do

Print a table that lines up, with headers and a total row.

Q14Menu DispatchEasyMust Do

Drive a menu from a dictionary of functions.

Q15Validation RulesEasy

Validate a form against a table of rules.

Q16Dates in RecordsEasy

Store and use dates inside records.

Q17JSON StorageEasyMust Do

Save records to a file and load them back.

Q18CSV StorageEasy

Read and write records as CSV, with types restored.

Q19IdentifiersEasy

Generate identifiers that do not collide.

Q20UndoEasy

Keep a history so an action can be undone.

Q21PagingEasy

Show a long list one page at a time.

Q22Text ChartsEasy

Draw a bar chart in the terminal.

Q23Testable InputEasyMust Do

Make an interactive program run the same way every time.

Q24Domain ExceptionsEasy

Give the program its own error types.

Q25Putting It TogetherEasyMust Do

Assemble the building blocks into one small working program.

Q26CRUDMediumMust Do

Build the four operations every record store needs: create, read, update, delete.

Q27TransactionsMedium

Move money between accounts, keeping a history and never losing a rupee.

Q28Shopping CartMedium

Build a cart with quantities, discounts and a printed bill.

Q29AttendanceMedium

Turn an attendance register into a percentage report.

Q30Quiz ScoringMediumMust Do

Score a quiz against an answer key, with negative marking and a breakdown.

Q31Login & LockoutMedium

Implement login attempts with a lockout, without storing plain passwords.

Q32Library LoansMedium

Issue and return books, enforcing limits and charging fines.

Q33BudgetsMedium

Compare spending against a budget and report the variance.

Q34DeduplicationMediumMust Do

Merge duplicate contacts without losing information.

Q35Reorder LevelsMedium

Decide what to reorder and how much.

Q36Seat BookingMedium

Book seats from a seat map, keeping groups together.

Q37Scaling QuantitiesMedium

Scale a recipe and convert its units sensibly.

Q38Splitting a BillMedium

Split a bill fairly, including a tip, with every paisa accounted for.

Q39LeaderboardsMediumMust Do

Rank players, handling ties the way a scoreboard should.

Q40Text ReportsMedium

Produce a word-frequency report from a text file.

Q41State MachinesMediumMust Do

Model an order's lifecycle so invalid transitions cannot happen.

Q42Tiered PricingMedium

Charge by tier, where each band is priced differently.

Q43ExportingMedium

Export the same report to text, CSV and JSON.

Q44Ranked SearchMedium

Search records and rank the matches by relevance.

Q45Batch ImportMedium

Import a batch of rows, accepting the good ones and reporting the rest.

Q46Layered ConfigMedium

Build settings from defaults, a file, the environment and the command line.

Q47Audit LoggingMediumMust Do

Record who did what, using a decorator so no call can be missed.

Q48CachingMedium

Cache an expensive lookup, and know when to clear it.

Q49RetryMedium

Retry a flaky operation with a backoff, and know when to give up.

Q50Testing Your Own CodeMedium

Write a tiny test harness and use it on the functions you have built.

Q51Task ManagerMediumMust Do

Build a complete menu-driven To-Do Manager with storage.

Q52ATMMedium

Build an ATM with a PIN, denominations and a receipt.

Q53Quiz RunnerMediumMust Do

Build a Quiz Runner that asks questions, keeps score and reviews mistakes.

Q54Expense TrackerMedium

Build an Expense Tracker with categories, months and a summary.

Q55Contact BookMediumMust Do

Build a Contact Book with search, edit and export.

Q56InventoryMedium

Build an Inventory System with stock movements and valuation.

Q57SchedulingMediumMust Do

Build an Appointment Booker with slots, clashes and cancellations.

Q58PayrollMediumMust Do

Build a Payroll Run with allowances, deductions and payslips.

Q59VotingMedium

Build a Voting System with candidates, validation and a result.

Q60ParkingMedium

Build a Parking Lot with levels, ticketing and charges.

Q61RecipesMedium

Build a Recipe Manager with search by ingredient and a shopping list.

Q62Habit TrackingMedium

Build a Fitness Log with goals, streaks and weekly summaries.

Q63Ticket QueueMedium

Build a Support Ticket Queue with priorities, assignment and SLAs.

Q64Spaced RepetitionMedium

Build a Flashcard Trainer with spaced repetition.

Q65Order SystemMedium

Build a Restaurant Order System with a kitchen queue and a bill.

Q66VersioningMedium

Build a Version-Controlled Notes store with history and diffs.

Q67CurrencyMedium

Build a Currency Converter with rates, cross-rates and a history.

Q68SurveysMedium

Build a Poll and Survey tool with several question types.

Q69Password VaultMedium

Build a Password Manager with generation, strength scoring and storage.

Q70ReservationsMedium

Build a Train Booking system with seats, fares and cancellations.

Q71DebuggingHardMust Do

This bank transfer sometimes loses money. Find the bug.

BALANCES = {"asha": 5000, "raj": 3000}
 
def transfer(source, target, amount):
    BALANCES[source] -= amount
    if amount > 20000:
        raise ValueError("transfer limit exceeded")
    BALANCES[target] += amount
 
try:
    transfer("asha", "raj", 50000)
except ValueError:
    pass
print(BALANCES, sum(BALANCES.values()))
Q72Mutable DefaultsHard

A shared default argument makes separate records share state.

Q73CopiesHard

A shallow copy is not enough for a nested record.

Q74Float MoneyHard

Watch a total drift when money is stored as a float.

Q75Iterating & MutatingHard

Removing items while looping skips some of them.

Q76Aliasing StateHard

Two parts of a program end up sharing one object by accident.

Q77Silent FailuresHardMust Do

A bare except hides the bug you are looking for.

Q78Growing CostHard

A lookup written as a scan gets slower as the data grows.

Q79Time BugsHard

datetime.now() inside the logic makes a program untestable and wrong at midnight.

Q80Modelling MistakesHardMust Do

Two parallel lists that must stay in step will eventually not.

Q81RoundingHard

Percentages that should add to 100 do not.

Q82Interface CreepHard

A function that grew too many flags is telling you to split it.

Q83Validation GapsHard

Validating in the wrong place lets bad data in through the side door.

Q84Bad KeysHard

Choosing the wrong dictionary key merges records that should be separate.

Q85Growing a ProgramHard

Watch a small script turn into an unmaintainable one, and refactor it back.

Q86Mini-ProjectMini-ProjectMust Do

Build a complete Student Management System.

Q87Mini-ProjectMini-Project

Build a complete Bank with accounts, statements and interest.

Q88Mini-ProjectMini-Project

Build a complete Library System with members, loans, reservations and fines.

Q89Mini-ProjectMini-Project

Build a complete Expense Manager with budgets, recurring items and a forecast.

Q90Mini-ProjectMini-Project

Build a complete Quiz Platform with question banks, sessions and analytics.

Q91Mini-ProjectMini-Project

Build a complete Inventory & Billing system for a small shop.

Q92Mini-ProjectMini-Project

Build a complete Hotel Booking system with rooms, rates and occupancy.

Q93Mini-ProjectMini-Project

Build a complete Fleet & Delivery tracker with routes and status.

Q94Mini-ProjectMini-ProjectMust Do

Build a complete Personal Finance Dashboard combining several systems.

Q95Mini-ProjectMini-Project

Build a complete Event Management system with tickets, capacity and refunds.

Q96InterviewInterview

Choose the right data structure for a record, and defend the choice.

Q97InterviewInterview

Explain where validation, business rules and formatting belong, and why.

Q98InterviewInterview

Design the error-handling strategy for a whole program.

Q99InterviewInterview

Take a working but poor program and refactor it, explaining each step.

Q100CapstoneInterviewMust Do

Build a Coaching Institute Management System โ€” the complete demonstration of this topic. Model students, courses, enrolments, fees, attendance and results, with validation, storage, reports and a menu.

Still stuck on something?

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

Book a Free Session