How to use this list
Work through them in order without looking at ready solutions. Stuck for half an hour? Look at a hint, then close it and write your own.
After each one, check the edge cases: empty input, a single element, all elements identical. That's what people most often forget at interviews.
The ten
1. Word frequency in a text. Read a file, count how often each word appears, print the ten most common.
Trains: files, strings, dictionaries, sorting.
2. Renaming files. Walk a folder and rename every file to a pattern: add a date, remove spaces, lowercase everything.
Trains: the file system, strings. Useful in real life too.
3. Parsing a table. Read a comma-separated file, compute the sum and mean of one column, print the rows above the mean.
Trains: structured data, type conversion, filtering.
4. Balanced brackets. Given a string with brackets of several kinds, decide whether they're correctly nested.
Trains: using a list as a stack. A classic interview problem.
5. Two numbers with a given sum. Find two numbers in a list that sum to a target. First by brute force, then in one pass with a dictionary.
Trains: understanding why a dictionary beats a list here.
6. Weather from a public source. Request data from a public service, parse the response, print it readably.
Trains: network requests, parsing, handling connection errors.
7. Expense tracking in a file. A program that takes commands: add an expense, show the monthly total, show totals by category. Data survives restarts.
Trains: persisting state, program structure, dates.
8. Checking sites for availability. Given a list of addresses, check each and print which don't respond.
Trains: networking, exception handling, lists.
9. Password generator. With parameters: length, digits, symbols. With validation of the parameters.
Trains: randomness, command-line arguments, input checking.
10. Log parsing. A file of log lines: find all errors, group them by type, print a summary for a period.
Trains: everything together. A good final check.
What to do afterwards
If all ten went without great pain, move to your own project. Beyond this point, exercises teach less than building something real.
A good exit test: take problem seven and take it to the point where you'd use it daily. That isn't an exercise any more — it's a first project.
Хватит читать — пора делать
На CohortX можно найти команду под пет-проект и получить тот самый опыт, о котором спрашивают на собеседовании.
Похожие статьи
- FastAPI: your first service in an eveningWhat a service for programs is, how to write your first one in an evening, and why automatic documentation saves time.
- FastAPI: первый сервис за вечерЧто такое сервис для программ, как написать первый за вечер и почему автоматическая документация экономит время.
- Django for beginners: a first project step by stepFrom installation to a working list with an admin panel — the steps, and what each one means.