Web Development
HTML Course
CSS Course
JavaScript Course
PHP Course
Python Course
SQL Course
SEO Course

Practical Projects in Python

This lesson challenges you to apply the concepts learned through six interactive projects. From simple console games to web applications and automation, each project develops your skills in a practical and creative way.

Included Projects

Each project comes with explanations, full code, and extension suggestions. You can customize them, combine them, or turn them into more complex applications.

Number Guessing Game - CLI Project in Python

This simple command-line game allows the user to guess a number randomly generated by the computer. It is ideal for practicing loops, conditions, and input handling.

Game Code

import random

secret_number = random.randint(1, 100)
attempts = 0

print("Guess the number between 1 and 100!")

while True:
    try:
        guessed = int(input("Enter a number: "))
        attempts += 1

        if guessed < secret_number:
            print("๐Ÿ“‰ Too low.")
        elif guessed > secret_number:
            print("๐Ÿ“ˆ Too high.")
        else:
            print(f"๐ŸŽ‰ Congratulations! You guessed it in {attempts} attempts.")
            break
    except ValueError:
        print("โš ๏ธ Enter a valid number.")

What You Practice

Possible Extensions

Simple Banking Application - CLI Project in Python

This application simulates a bank account in the command line. The user can check the balance, deposit money, and withdraw funds. It is ideal for practicing functions, conditional structures, and loops.

Application Code

balance = 1000

def display_menu():
    print("\n๐Ÿ’ณ Banking Menu")
    print("1. Check balance")
    print("2. Deposit money")
    print("3. Withdraw money")
    print("4. Exit")

while True:
    display_menu()
    option = input("Choose an option: ")

    if option == "1":
        print(f"๐Ÿ’ฐ Current balance is: {balance} GBP")
    elif option == "2":
        amount = float(input("Enter deposit amount: "))
        balance += amount
        print(f"โœ… You deposited {amount} GBP.")
    elif option == "3":
        amount = float(input("Enter withdrawal amount: "))
        if amount <= balance:
            balance -= amount
            print(f"โœ… You withdrew {amount} GBP.")
        else:
            print("โŒ Insufficient funds.")
    elif option == "4":
        print("๐Ÿ‘‹ Goodbye!")
        break
    else:
        print("โš ๏ธ Invalid option.")

What You Practice

Possible Extensions

Mini CLI Chat - Interactive Project in Python

This project simulates a conversation between two users in the command line. Messages are saved in a text file, and each user can read and send messages. It is ideal for practicing file handling and interactive loops.

Application Code

def send_message(name):
    message = input(f"{name} says: ")
    with open("chat.txt", "a") as f:
        f.write(f"{name}: {message}\n")

def display_chat():
    print("\n๐Ÿ“œ Chat History:")
    try:
        with open("chat.txt", "r") as f:
            print(f.read())
    except FileNotFoundError:
        print("๐Ÿ’ฌ The chat is empty.")

print("๐Ÿ’ฌ Mini CLI Chat - type 'exit' to quit.")

while True:
    display_chat()
    user = input("Who is writing (User1/User2)? ")
    if user.lower() == "exit":
        break
    send_message(user)

What You Practice

Possible Extensions

Tic-Tac-Toe in Console - Interactive Game in Python

This project implements the classic "X and O" game in the command line. Two players alternate moves on a 3x3 board, and the program automatically checks for a winner or a draw.

Game Code

board = [" "]*9

def display_board():
    print(f"""
 {board[0]} | {board[1]} | {board[2]}
---+---+---
 {board[3]} | {board[4]} | {board[5]}
---+---+---
 {board[6]} | {board[7]} | {board[8]}
""")

def check_winner(symbol):
    combinations = [
        [0,1,2], [3,4,5], [6,7,8],  # rows
        [0,3,6], [1,4,7], [2,5,8],  # columns
        [0,4,8], [2,4,6]            # diagonals
    ]
    return any(all(board[i] == symbol for i in c) for c in combinations)

player = "X"
while True:
    display_board()
    try:
        position = int(input(f"Player {player}, choose a position (0โ€“8): "))
        if board[position] == " ":
            board[position] = player
            if check_winner(player):
                display_board()
                print(f"๐Ÿ† Player {player} won!")
                break
            elif " " not in board:
                display_board()
                print("๐Ÿค Draw!")
                break
            player = "O" if player == "X" else "X"
        else:
            print("โš ๏ธ Position already taken.")
    except (ValueError, IndexError):
        print("โš ๏ธ Enter a valid number between 0 and 8.")

What You Practice

Possible Extensions

Automation - Web Scraping with requests + BeautifulSoup

This project demonstrates how to extract data from a web page using the requests and BeautifulSoup libraries. It is ideal for automating online data collection.

Application Code

import requests
from bs4 import BeautifulSoup

url = "https://quotes.toscrape.com"
r = requests.get(url)
soup = BeautifulSoup(r.text, "html.parser")

quotes = soup.find_all("span", class_="text")

print("๐Ÿ“œ Extracted Quotes:")
for q in quotes:
    print(q.text)

What You Practice

Possible Extensions

Simple Web Application with Flask - Python Web Project

This project builds a basic web application using the Flask framework. It is ideal for starting web development in Python and understanding routes, templates, and the local server.

Application Code

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "๐Ÿ‘‹ Hello, John! Welcome to your Flask application."

@app.route("/about")
def about():
    return "๐ŸŒ This is a simple web application created with Flask."

if __name__ == "__main__":
    app.run(debug=True)

What You Practice

Possible Extensions

Top