Learning hub
Python exercises: 165+ practice problems with solutions
Stop reading about Python. Start writing it.
This page gives you 165+ Python practice problems organized by topic and difficulty—from your first print() statement to file handling and object-oriented programming. Every exercise includes a working solution so you can check your approach, see idiomatic patterns, and move forward faster.
Whether you just finished Day 1 of the Python course or you are brushing up before a technical interview, the right exercise is one click away.
What's inside this Python exercises collection
Real counts from our program bank—no rounded marketing guesses. Each topic links to every exercise with solutions.
| Topic | Difficulty | Problems |
|---|---|---|
| Basic Python Programs | Beginner | 25 |
| Conditional Programs | Beginner | 20 |
| Loop Programs | Beginner – Intermediate | 25 |
| String Programs | Intermediate | 25 |
| List Programs | Intermediate | 25 |
| Object-Oriented Programs | Intermediate – Advanced | 25 |
| File Handling Programs | Advanced | 20 |
| Total | 165 | |
Each problem targets a specific concept so practice time converts into skill—not repetition for inflated numbers.
Beginner Python exercises
If you just started, work through Basic Python Programs first: variables, I/O, basic math, and simple logic. The goal is muscle memory, not clever one-liners.
What you will practice: printing output, variables, arithmetic, type conversion, input.
Sample problems
- Swap two variables without a third variable.
- Simple calculator: two numbers and an operator (+, −, ×, ÷).
- Celsius to Fahrenheit using F = (C × 9/5) + 32.
Python conditional exercises
Branching and edge cases. Practice if / elif / else, comparisons, and logical operators.
- FizzBuzz from 1–50 (multiples of 3 / 5 / both).
- Largest of three numbers without
max(). - Letter grade from a 0–100 score.
Python loop exercises
for, while, nested loops, range(), patterns, and accumulation.
- Sum of digits of a positive integer.
- Multiplication table for a user-entered number.
- Reverse digits without string conversion.
- Star / number patterns with nested loops.
Python string exercises
Slicing, methods, formatting, palindromes, anagrams, and character counting.
- Reverse a string without the
[::-1]shortcut. - Count vowels (case-insensitive).
- Palindrome check ignoring spaces and case.
- Anagram check for two strings.
Python list exercises
Indexing, methods, comprehensions, search, nested lists, and rotations.
- Remove duplicates while preserving order.
- Second largest without
sort()ormax(). - Flatten a nested list.
- Rotate a list to the right by k positions.
Python OOP exercises
Classes, __init__, methods, inheritance, encapsulation, and modeling real entities.
- Bank account with deposit, withdraw, and non-negative balance.
- Student grade book with average / min / max.
- Shape hierarchy with
area()on subclasses. - Employee and manager with team membership.
Python file handling exercises
open(), read/write/append, line iteration, and simple CSV-style processing.
- Word count from a text file.
- Reverse line order into a new file.
- Find-and-replace across a file.
- Top score from a CSV of names and scores.
How to use these Python exercises effectively
- Read the problem once, then try without the solution for at least 10 minutes. Note what you tried.
- Match exercises to the chapter you just finished—same day if possible.
- After solving, read the solution anyway; compare style and edge cases.
- Keep a short error log: mistake → why → fix. Revisit weekly.
- Redo problems that felt slow after a week until they feel automatic.
Python exercises by difficulty
- Just started (weeks 1–2): Basic → Conditionals → Loops.
- Comfortable with basics: Strings and lists — high leverage for interviews and apps.
- Ready for serious projects: OOP and file handling.
Test your Python knowledge
The Schoolabe Python quiz has 300 multiple-choice questions with explanations—good for a quick check after a topic block.
Take the Python quiz →Learn the concepts behind the exercises
Exercises make you faster; the Python course makes you deeper. If a topic feels fuzzy, jump to the matching chapter below (all crawlable chapter URLs).
| Struggling with | Go to chapter |
|---|---|
| Basic programs | Day 1: Introduction to Python |
| Variables and types | Day 2: Variables and Data Types |
| Conditionals | Day 8: Conditional Statements |
| Loops | Day 9: Loops and Iteration |
| Strings | Day 4: Strings and String Methods |
| Lists | Day 5: Lists and List Methods |
| OOP | Day 11: Classes and Objects |
| File handling | Day 14: File Handling |
All Python course chapters
Day 1: Introduction to Python
20 min · Beginner
Day 2: Variables and Data Types
25 min · Beginner
Day 3: Operators and Expressions
30 min · Beginner
Day 4: Strings and String Methods
35 min · Beginner
Day 5: Lists and List Methods
40 min · Beginner
Day 6: Tuples and Sets
35 min · Beginner
Day 7: Dictionaries
35 min · Beginner
Day 8: Conditional Statements
40 min · Beginner
Day 9: Loops and Iteration
45 min · Beginner
Day 10: Functions
50 min · Intermediate
Day 11: Classes and Objects
45 min · Intermediate
Day 12: Inheritance and Polymorphism
50 min · Intermediate
Day 13: Modules and Packages
40 min · Intermediate
Day 14: File Handling
45 min · Intermediate
Day 15: Exception Handling
40 min · Intermediate
Day 16: Advanced Data Structures
50 min · Advanced
Day 17: Basic Algorithms
55 min · Advanced
Day 21: Web Development Basics
60 min · Advanced
Day 22: Working with APIs
55 min · Advanced
Day 23: Database Operations
60 min · Advanced
Frequently asked questions
How many Python exercises are on Schoolabe?
Schoolabe has over 165 Python practice problems organized across seven topic areas: basic programs, conditionals, loops, strings, lists, object-oriented programming, and file handling. Each exercise includes a complete solution and explanation.
Are solutions included with every exercise?
Yes. Every exercise includes a full working solution and explanation. The goal is to help you compare approaches, fix mistakes faster, and build patterns you can reuse.
What level are these Python exercises?
The collection spans beginner through advanced. Basic programs, conditionals, and loops suit beginners. String and list problems are intermediate. Object-oriented and file-handling exercises are for learners moving toward real projects and interviews.
Do I need to install Python to practice?
No installation is required to read problems and solutions in the browser. To type and run your own code, use any free Python environment (IDLE, Replit, VS Code, or an online interpreter).
How do these exercises connect to the Python course?
Each topic maps to chapters in the free Schoolabe Python course. The recommended flow is: study a chapter, then solve the matching exercises before moving on—so concepts stay connected to muscle memory.
Are these exercises enough to prepare for a Python interview?
They build core problem-solving patterns that interviews rely on. For Q&A-style prep, use the Python Interview Questions hub and the timed Python quiz for quick knowledge checks.
What should I practice first if I am a complete beginner?
Start with Basic Python Programs, then Conditional Programs, then Loop Programs—in that order. Skipping fundamentals usually costs more time later than doing them carefully now.
How should I use this Python exercises hub page?
Use it to pick the right topic, jump into programs with solutions, and return to the course when a concept feels fuzzy. Pair short practice sessions with the full chapter explanations for the fastest progress.
Related hubs
- Python tutorial roadmap
- Python interview questions
- Python cheatsheet
- Python programs (all topics)
- Mixed coding practice(multi-language from catalog)