Python Mini Projects
In this page:
Simple Calculator
A terminal-based calculator ties together user input, string-to-number conversion, and conditional logic for choosing an operation -- a compact project that exercises several fundamentals (input parsing, arithmetic, error handling for bad input) at once.
Example: Simple Calculator
def calculate(a, b, op):
if op == "+":
return a + b
elif op == "-":
return a - b
return None
print(calculate(5, 3, "+"))
Word Density Counter
A word-frequency counter splits input text into individual words and tallies how often each one appears using a dictionary (or collections.Counter), a practical exercise in string processing that scales naturally to analyzing real documents or user-submitted text.
Example: Word Density Counter
from collections import Counter
text = "the cat sat on the mat"
counts = Counter(text.split())
print(counts)
Custom Password Generator
A password generator uses the random module to assemble a string of randomly chosen letters, digits, and symbols into a secure key of a requested length -- a good project for practicing string building alongside random selection.
Example: Custom Password Generator
import random
import string
random.seed(1)
chars = string.ascii_letters + string.digits
password = "".join(random.choice(chars) for _ in range(8))
print(password)
Text Guessing Game
A number-guessing game picks a random target number and repeatedly compares the player's guesses against it inside a loop, giving higher/lower feedback until the correct number is found -- a simple but complete exercise in loops, conditionals, and user interaction.
Example: Text Guessing Game
import random
random.seed(1)
target = random.randint(1, 10)
guess = 5
if guess < target:
print("Higher")
elif guess > target:
print("Lower")
else:
print("Correct!")
Basic File Organizer
A file organizer script scans a directory's filenames, inspects each one's extension, and sorts files into subfolders by type -- a practical automation project that combines the os/pathlib modules with basic string handling on real filesystem data.
Example: Basic File Organizer
import os
os.makedirs("demo_files/images", exist_ok=True)
with open("demo_files/photo.jpg", "w") as f:
f.write("fake image data")
for filename in os.listdir("demo_files"):
if filename.endswith(".jpg"):
print(filename, "-> images/")
Chapter Quiz — Complete all 15 topics to unlock
0/15 topics done
Complete these topics first:
- Python PEP 8 Style Guide
- Python Debugging Techniques
- Python Testing with unittest
- Python Common Mistakes
- Python Interview Questions
- Python map() & filter()
- Python reduce()
- Python zip() & enumerate()
- Python sorted() & key Functions
- Python Comprehensions Advanced
- Python Turtle Graphics
- Python tkinter Introduction
- Python tkinter Widgets
- Python pygame Introduction
- Python Mini Projects