Python Projects

Explore Python projects from beginner to advanced levels to enhance your programming skills.

Beginner Python Projects

1. Hello World Program

This is the most basic Python program, which prints "Hello, World!" to the screen.

print("Hello, World!")

2. Simple Calculator

A calculator that performs basic arithmetic operations.

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

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

print(add(5, 3))
print(subtract(10, 4))

Intermediate Python Projects

1. To-Do List App

A simple console-based to-do list application to manage tasks.

tasks = []

def add_task(task):
    tasks.append(task)

def show_tasks():
    for task in tasks:
        print(task)

add_task("Finish Python tutorial")
show_tasks()

2. Password Generator

Generates a random password of a specified length with letters, numbers, and symbols.

import random
import string

def generate_password(length=8):
    characters = string.ascii_letters + string.digits + string.punctuation
    return ''.join(random.choice(characters) for i in range(length))

print(generate_password(12))

Advanced Python Projects

1. Web Scraper

Scrapes data from a website and stores it in a CSV file.

import requests
from bs4 import BeautifulSoup
import csv

url = "http://example.com"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

with open("data.csv", "w") as file:
    writer = csv.writer(file)
    writer.writerow(["Title", "Link"])
    for item in soup.find_all('a'):
        writer.writerow([item.text, item.get('href')])

2. Weather App

A weather application that fetches current weather data from an API.

import requests

def get_weather(city):
    api_key = "your_api_key"
    url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}"
    response = requests.get(url)
    data = response.json()
    print(data["weather"][0]["description"])

get_weather("New York")