25. Final Projects in Python

Final projects help apply all Python concepts in real-world applications.

These projects improve:

  • Problem-solving skills
  • Coding experience
  • Portfolio quality
  • Practical understanding

Suggested Final Projects

  1. Calculator App
  2. To-Do Application
  3. Chat Application
  4. Web Scraper
  5. Data Dashboard
  6. Machine Learning Project
  7. REST API Project

1. Calculator App

A calculator performs arithmetic operations.

Concepts Used:

  • Variables
  • Functions
  • Conditions
  • GUI (optional)

Console Calculator

def add(a, b):
return a + b

def subtract(a, b):
return a - b

def multiply(a, b):
return a * b

def divide(a, b):

if b == 0:
return "Cannot divide by zero"

return a / b

print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")

choice = input("Choose option: ")

num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

if choice == "1":
print(add(num1, num2))

elif choice == "2":
print(subtract(num1, num2))

elif choice == "3":
print(multiply(num1, num2))

elif choice == "4":
print(divide(num1, num2))

else:
print("Invalid choice")

GUI Calculator (Tkinter)

import tkinter as tk

def calculate():

result = eval(entry.get())

label.config(text=result)

root = tk.Tk()

entry = tk.Entry(root)

entry.pack()

button = tk.Button(
root,
text="Calculate",
command=calculate
)

button.pack()

label = tk.Label(root)

label.pack()

root.mainloop()

2. To-Do Application

A to-do app manages tasks.

Features:

  • Add tasks
  • Delete tasks
  • Mark completed tasks

Simple To-Do App

tasks = []

while True:

print("\n1. Add Task")
print("2. View Tasks")
print("3. Exit")

choice = input("Choose: ")

if choice == "1":

task = input("Enter task: ")

tasks.append(task)

elif choice == "2":

for index, task in enumerate(tasks):

print(index + 1, task)

elif choice == "3":
break

3. Chat Application

A chat app allows communication between users.

Concepts Used:

  • Socket programming
  • Networking
  • Multithreading

Server Code

import socket

server = socket.socket()

server.bind(("localhost", 12345))

server.listen(1)

client, addr = server.accept()

while True:

message = client.recv(1024)

print("Client:", message.decode())

Client Code

import socket

client = socket.socket()

client.connect(("localhost", 12345))

while True:

message = input("You: ")

client.send(message.encode())

4. Web Scraper

Extracts information from websites.

Concepts Used:

  • Requests
  • BeautifulSoup
  • Automation

Example Web Scraper

import requests
from bs4 import BeautifulSoup

url = "https://example.com"

response = requests.get(url)

soup = BeautifulSoup(
response.text,
"html.parser"
)

print(soup.title.text)

Extract All Links

for link in soup.find_all("a"):

print(link.get("href"))

5. Data Dashboard

Displays charts and analytics.

Concepts Used:

  • Pandas
  • Matplotlib
  • Streamlit or Flask

Install Streamlit

pip install streamlit

Dashboard Example

import streamlit as st
import pandas as pd

data = {
"Month": ["Jan", "Feb", "Mar"],
"Sales": [100, 200, 150]
}

df = pd.DataFrame(data)

st.title("Sales Dashboard")

st.line_chart(df["Sales"])

Run app:

streamlit run app.py

6. Machine Learning Project

Build predictive systems using ML.

Examples:

  • House price prediction
  • Spam detection
  • Student score prediction

Student Score Prediction

from sklearn.linear_model import LinearRegression
import numpy as np

hours = np.array([
[1],
[2],
[3],
[4]
])

scores = np.array([
20,
40,
60,
80
])

model = LinearRegression()

model.fit(hours, scores)

prediction = model.predict([[5]])

print(prediction)

7. REST API Project

Create APIs using Flask.

Concepts Used:

  • Flask
  • JSON
  • CRUD operations

Simple Flask API

from flask import Flask, jsonify

app = Flask(__name__)

@app.route("/")

def home():
return "API Running"

@app.route("/users")

def users():

data = [
{"name": "Aditya"},
{"name": "Rahul"}
]

return jsonify(data)

app.run(debug=True)

Advanced REST API Example

from flask import Flask, request, jsonify

app = Flask(__name__)

students = []

@app.route("/students", methods=["POST"])
def add_student():

data = request.json

students.append(data)

return jsonify({
"message": "Student added"
})

@app.route("/students", methods=["GET"])
def get_students():

return jsonify(students)

app.run(debug=True)

Suggested Improvements

You can enhance projects by adding:

  • Database support
  • Authentication
  • GUI
  • Cloud deployment
  • Docker support

Project Folder Structure Example

project/

├── app.py
├── requirements.txt
├── templates/
├── static/
└── database.db

GitHub Portfolio Tips

Upload projects to GitHub with:

  • README.md
  • Screenshots
  • Requirements file
  • Proper documentation

Example requirements.txt

flask
requests
pandas
numpy
scikit-learn

Best Practices

✅ Write clean code
✅ Use virtual environments
✅ Add comments and documentation
✅ Handle errors properly
✅ Use Git for version control


Capstone Project Ideas

Advanced ideas:

  • AI chatbot
  • Expense tracker
  • Weather application
  • Face recognition system
  • E-commerce backend
  • Social media API

Summary

In this chapter you learned:

✅ Calculator project
✅ To-do application
✅ Chat application
✅ Web scraper
✅ Data dashboard
✅ Machine learning project
✅ REST API project