This repository contains a curated list of 100 Python exercises, from beginner to expert level, to help you master Python through hands-on problem solving.
-
Hello World
Print"Hello, World!"to the console. -
User Input Greeting
Ask the user for their name usinginput()and print a personalized greeting like"Hello, John!". -
Swap Two Numbers
Swap two variablesa = 5,b = 10without using a third variable. Print the swapped values. -
Even or Odd
Given a number input by the user, check if it is even or odd using the modulus operator%. -
Largest of Three Numbers
Compare three numbers (e.g.,a = 12, b = 25, c = 9) and print the largest. -
Prime Number Check
Take an integer input from the user and print whether it is a prime number. -
Fibonacci Series
Print the first 10 Fibonacci numbers starting from 0. -
Factorial Calculation
Write a function that takes a number and returns its factorial using recursion. -
Multiplication Table
Ask the user for a number and print its multiplication table up to 10. -
Reverse a String
Input a string and print its reverse (e.g.,"hello"→"olleh"). -
Vowel Count
Count how many vowels appear in a string like"I'm learning Python". -
Palindrome Check
Check whether the word"radar"is a palindrome. -
Remove Duplicates
Remove duplicates from the list[1, 2, 2, 3, 4, 4, 5]and return[1, 2, 3, 4, 5]. -
Sum of List
Calculate the sum of elements in the list[10, 20, 30, 40, 50]. -
Sort List Ascending
Sort the list[5, 3, 8, 1, 9]in ascending order using a loop or thesorted()function. -
Max and Min in List
Find the largest and smallest numbers in[12, 55, 2, 98, 1]. -
Frequency Counter
Count the frequency of elements in["apple", "banana", "apple", "orange", "banana"]. -
Simple Calculator
Create a program that asks the user for two numbers and performs all basic arithmetic operations. -
Celsius to Fahrenheit
Ask the user for a Celsius temperature and convert it to Fahrenheit. -
List Comprehension Squares
Generate a list of squares from 1 to 10 using list comprehension:[1, 4, 9, ...]. -
Merge Dictionaries
Mergedict1 = {"a": 1, "b": 2}withdict2 = {"c": 3, "d": 4}. -
List Length Without
len()
Count how many elements are in[1, 2, 3, 4, 5, 6]without using thelen()function. -
String Case Conversion
Convert the string"Python Is Fun"to lowercase and uppercase. -
Substring Search
Check if the word"fun"is present in the string"Python is fun to learn". -
Print Odd Numbers
Print all odd numbers from 1 to 100 using a loop andifcondition.
-
Common Elements in Lists
Find common items in[1, 2, 3, 4]and[3, 4, 5, 6]→[3, 4]. -
Remove Punctuation
Remove all punctuation from"Hello, World! Welcome...". -
Sort Dictionary by Value
Sort{'a': 3, 'b': 1, 'c': 2}by value. -
Use
map()andfilter()
Square a list withmap()and filter even numbers usingfilter()on[1, 2, 3, 4, 5]. -
Anagram Checker
Check if"listen"and"silent"are anagrams. -
Flatten Nested List
Flatten[[1, 2], [3, 4], [5]]to[1, 2, 3, 4, 5]. -
Second Largest Element
Find the second largest number in[3, 5, 1, 9, 7]. -
Word Count in String
Count how many words in"This is a sample sentence.". -
Check Sorted List
Determine if[1, 2, 3, 4, 5]is sorted. -
Binary Search
Perform binary search to find 7 in[1, 3, 5, 7, 9]. -
List to Dictionary
Convert[("a", 1), ("b", 2)]into a dictionary. -
Random Password Generator
Generate a random password with length 8 including letters and digits. -
Number Guessing Game
User tries to guess a number between 1 and 100 until correct. -
Email Validator
Check ifuser@example.comis a valid email using regex. -
File Read/Write
Write"Hello"to a file and then read it. -
Paragraph Word Frequency
Count the frequency of each word in a multi-line string. -
Extract Digits from String
Extract digits from"abc123def456"→[1,2,3,4,5,6]. -
Contact Book CLI
Create a contact book: Add, remove, and list contacts. -
To-Do List App
Implement CLI for adding/removing/listing tasks. -
Replace Spaces with Hyphens
Replace all spaces in"Hello World Python"→"Hello-World-Python". -
Diamond Pattern
Print a diamond star pattern of height 5. -
Decimal to Binary Converter
Convert25into binary manually. -
Case Counter
Count uppercase and lowercase letters in"PyTHon". -
Armstrong Numbers in Range
Print all 3-digit Armstrong numbers. -
LCM and GCD Calculator
Calculate LCM and GCD of8and12. -
Stack with List
Push and pop elements using a list as a stack. -
Queue with List
Enqueue and dequeue elements from a list. -
Zip and Merge Lists
Combine['a', 'b']and[1, 2]into[('a',1), ('b',2)]. -
Countdown Timer
Countdown from 10 to 0 withtime.sleep(). -
Calendar Display
Display calendar for August 2025 usingcalendar. -
Lambda Sorting
Sort[(1, 'a'), (3, 'c'), (2, 'b')]by the second element. -
Dice Simulator
Simulate rolling a dice usingrandom.randint(). -
List Shuffler
Shuffle a list randomly. -
URLify a String
Replace spaces in"Hello World"with%20. -
CSV Column Counter
Read a CSV file and count values in a specific column.
-
Singly Linked List
Implement a basic singly linked list with insert and display methods. -
Execution Time Decorator
Write a decorator to log function execution time. -
OOP with Inheritance
Create aVehicleclass and subclassCarwith unique behavior. -
Method Overriding
Override a method in the child class. -
Static and Class Methods
Use@staticmethodand@classmethodin a class. -
Custom Iterator
Build a custom iterator for squares of numbers up to N. -
Bank Account Class
Create a class with deposit/withdrawal methods and balance tracking. -
Pickle Serialization
Serialize a dictionary and save/load it usingpickle. -
Prime Number Generator
Useyieldto make an infinite prime number generator. -
Command-Line Calculator
Build a calculator usingargparse. -
Regex Date Extractor
Extract all dates from a string like"Today is 12/07/2025". -
Login System with Hashing
Create a system that stores hashed passwords usinghashlib. -
Web Scraper
Scrape titles from a blog usingrequestsandBeautifulSoup. -
SQLite CRUD
Perform create, read, update, delete operations with SQLite. -
Build a Flask API
Make a simple REST API with Flask and return JSON responses. -
Stack with Error Handling
Extend your stack to handle underflow/overflow exceptions. -
Tic-Tac-Toe Game
Create a 2-player command-line game. -
Rule-based Chatbot
Respond to user greetings like"hi"or"bye"using if/else. -
Quiz Game with JSON
Load questions and answers from a JSON file and quiz the user. -
Parse Nested JSON
Extract specific data from nested JSON. -
Custom List Class
Implement a class that mimics list behavior (append, remove). -
Shopping Cart System
Simulate adding/removing items and calculating total. -
Unit Test with unittest
Write test cases for a calculator app. -
Image Downloader
Download an image from a URL usingrequests. -
Memoization with lru_cache
Usefunctools.lru_cacheto optimize a recursive function.
-
N-Queens Solver
Solve the N-Queens puzzle using backtracking. -
Recursive File Explorer
List all files and folders recursively from a given path. -
Merge Sort Implementation
Implement merge sort manually. -
Quick Sort Implementation
Implement quick sort manually. -
Sudoku Solver
Create a solver that uses backtracking to solve Sudoku boards. -
Paginated Web Scraper
Scrape all product pages from a paginated site. -
Multithreaded Downloader
Download multiple files in parallel using threads. -
Autocomplete with Trie
Build an autocomplete system using the Trie data structure. -
Keylogger (Ethical)
Log keystrokes for personal keyboard learning use (not for misuse). -
Custom Encryption/Decryption
Design a reversible string encryption method. -
Train ML Model with Scikit-learn
Train a simple model usingscikit-learnto predict house prices. -
Snake Game in Terminal
Create a Snake game usingcurses. -
Telegram Bot
Create a Telegram bot that responds to/startcommand. -
Distribute CLI Tool
Build a command-line app and publish withsetuptools. -
Publish to PyPI
Create your own Python package and upload it to PyPI.
This project is open-source and free to use under the MIT License.