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.

TopicDifficultyProblems
Basic Python ProgramsBeginner25
Conditional ProgramsBeginner20
Loop ProgramsBeginner – Intermediate25
String ProgramsIntermediate25
List ProgramsIntermediate25
Object-Oriented ProgramsIntermediate – Advanced25
File Handling ProgramsAdvanced20
Total165

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.

Solve all basic Python programs →

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.
Solve all conditional programs →

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.
Solve all loop programs →

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.
Solve all string programs →

Python list exercises

Indexing, methods, comprehensions, search, nested lists, and rotations.

  • Remove duplicates while preserving order.
  • Second largest without sort() or max().
  • Flatten a nested list.
  • Rotate a list to the right by k positions.
Solve all list programs →

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.
Solve all object-oriented programs →

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.
Solve all file handling programs →

How to use these Python exercises effectively

  1. Read the problem once, then try without the solution for at least 10 minutes. Note what you tried.
  2. Match exercises to the chapter you just finished—same day if possible.
  3. After solving, read the solution anyway; compare style and edge cases.
  4. Keep a short error log: mistake → why → fix. Revisit weekly.
  5. Redo problems that felt slow after a week until they feel automatic.

Python exercises by difficulty

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).

All Python course chapters

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.