← Back to Python Course | Chapter 14: Advanced Python & Tools | Lesson 15 of 15

Python Mini Projects

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

python
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

python
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

python
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

python
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

python
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/")

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.