diff --git a/Advanced_Extractive_Text_Summarization/README.md b/Advanced_Extractive_Text_Summarization/README.md new file mode 100644 index 0000000..d621105 --- /dev/null +++ b/Advanced_Extractive_Text_Summarization/README.md @@ -0,0 +1,26 @@ +# Advanced Extractive Text Summarization + +An advanced extractive text summarization model using NLP techniques. + +## Features +- Extracts key sentences from text +- Scores sentences using TF-IDF, sentence length, position, and named entities +- Clusters sentences via K-means to highlight critical points from thematic groups + +## Usage +1. Install dependencies: + ```bash + pip install nltk spacy scikit-learn + python -m spacy download en_core_web_sm + ``` +2. Run `summarizer.py`. +3. The script will print a summary of the sample text. + +## Requirements +- Python 3.x +- nltk +- spacy +- scikit-learn + +## License +MIT diff --git a/Advanced_Extractive_Text_Summarization/requirements.txt b/Advanced_Extractive_Text_Summarization/requirements.txt new file mode 100644 index 0000000..3234307 --- /dev/null +++ b/Advanced_Extractive_Text_Summarization/requirements.txt @@ -0,0 +1,3 @@ +nltk +spacy +scikit-learn diff --git a/Advanced_Extractive_Text_Summarization/summarizer.py b/Advanced_Extractive_Text_Summarization/summarizer.py new file mode 100644 index 0000000..2036b04 --- /dev/null +++ b/Advanced_Extractive_Text_Summarization/summarizer.py @@ -0,0 +1,50 @@ +""" +Advanced Extractive Text Summarization Model +Issue #100 for king04aman/All-In-One-Python-Projects +""" +import nltk +import spacy +from sklearn.feature_extraction.text import TfidfVectorizer +from sklearn.cluster import KMeans +import numpy as np + +nltk.download('punkt') +nlp = spacy.load('en_core_web_sm') + +def extract_sentences(text): + return nltk.sent_tokenize(text) + +def score_sentences(sentences): + tfidf = TfidfVectorizer().fit_transform(sentences) + scores = tfidf.sum(axis=1).A1 + features = [] + for i, sent in enumerate(sentences): + length = len(sent) + position = i / len(sentences) + doc = nlp(sent) + entities = len(doc.ents) + features.append([scores[i], length, position, entities]) + return np.array(features) + +def cluster_sentences(features, n_clusters=3): + kmeans = KMeans(n_clusters=n_clusters, random_state=42) + labels = kmeans.fit_predict(features) + return labels + +def summarize(text, n_clusters=3): + sentences = extract_sentences(text) + features = score_sentences(sentences) + labels = cluster_sentences(features, n_clusters) + summary = [] + for cluster in range(n_clusters): + idx = np.where(labels == cluster)[0] + if len(idx) > 0: + best = idx[np.argmax(features[idx, 0])] + summary.append(sentences[best]) + return "\n".join(summary) + +if __name__ == "__main__": + sample_text = """ + Natural Language Processing (NLP) is a field of artificial intelligence that focuses on the interaction between computers and humans through language. NLP techniques are used to analyze text, extract information, and generate summaries. Extractive summarization selects key sentences from the original text to create a concise summary. Advanced models use features like TF-IDF, sentence length, position, and named entities to score sentences. Clustering helps group related sentences and highlight critical points from different themes. This approach is useful for summarizing reports, research papers, and news articles. + """ + print("Summary:\n", summarize(sample_text)) diff --git a/Analog_Wall_Clock/README.md b/Analog_Wall_Clock/README.md new file mode 100644 index 0000000..9d30f41 --- /dev/null +++ b/Analog_Wall_Clock/README.md @@ -0,0 +1,31 @@ +# Analog Wall Clock + +A real-time analog wall clock built using Python’s turtle graphics and threading. + +## Features +- Hour, minute, and second hands update in real time +- Decorative clock face with numbers and circles +- AM/PM indicator +- Hands rotate in sync with system time + +## Technologies Used +- Python +- turtle (graphics) +- threading (concurrent hand updates) +- datetime (system time) + +## Usage +1. Run `clock.py`. +2. The clock window will appear and update in real time. + +## Requirements +- Python 3.x +- turtle (usually included with Python) + +## Extensibility +- Add digital clock overlay +- Custom themes (dark/light mode) +- Alarm feature or tick sounds + +## License +MIT diff --git a/Analog_Wall_Clock/clock.py b/Analog_Wall_Clock/clock.py new file mode 100644 index 0000000..1bd4cc9 --- /dev/null +++ b/Analog_Wall_Clock/clock.py @@ -0,0 +1,144 @@ +""" +Analog Wall Clock using Python Turtle and Threading +Issue #107 for king04aman/All-In-One-Python-Projects +""" +import turtle +import threading +import time +from datetime import datetime + +WIDTH, HEIGHT = 600, 600 + +# Setup screen +def setup_screen(): + screen = turtle.Screen() + screen.title("Analog Wall Clock") + screen.bgcolor("white") + screen.setup(width=WIDTH, height=HEIGHT) + screen.tracer(0) + return screen + +# Draw clock face +def draw_clock_face(clock_turtle): + clock_turtle.penup() + clock_turtle.goto(0, -250) + clock_turtle.pendown() + clock_turtle.pensize(5) + clock_turtle.color("black") + clock_turtle.circle(250) + clock_turtle.penup() + clock_turtle.goto(0, 0) + clock_turtle.pendown() + # Draw numbers + for i in range(1, 13): + angle = i * 30 + x = 200 * turtle.sin(turtle.radians(angle)) + y = 200 * turtle.cos(turtle.radians(angle)) + clock_turtle.penup() + clock_turtle.goto(x, y-20) + clock_turtle.pendown() + clock_turtle.write(str(i), align="center", font=("Arial", 18, "bold")) + # Decorative circles + clock_turtle.penup() + clock_turtle.goto(0, -220) + clock_turtle.pendown() + clock_turtle.pensize(2) + clock_turtle.color("gray") + clock_turtle.circle(220) + clock_turtle.penup() + clock_turtle.goto(0, -180) + clock_turtle.pendown() + clock_turtle.circle(180) + clock_turtle.penup() + clock_turtle.goto(0, 0) + clock_turtle.pendown() + +# Draw AM/PM indicator +def draw_ampm_indicator(clock_turtle): + now = datetime.now() + ampm = "AM" if now.hour < 12 else "PM" + clock_turtle.penup() + clock_turtle.goto(0, 120) + clock_turtle.pendown() + clock_turtle.color("blue") + clock_turtle.write(ampm, align="center", font=("Arial", 16, "italic")) + clock_turtle.penup() + clock_turtle.goto(0, 0) + clock_turtle.pendown() + +# Hand drawing functions +def draw_hand(hand_turtle, length, angle, color, width): + hand_turtle.clear() + hand_turtle.penup() + hand_turtle.goto(0, 0) + hand_turtle.setheading(90) + hand_turtle.right(angle) + hand_turtle.pendown() + hand_turtle.pensize(width) + hand_turtle.color(color) + hand_turtle.forward(length) + hand_turtle.penup() + hand_turtle.goto(0, 0) + hand_turtle.pendown() + +# Thread functions +def update_second_hand(hand_turtle): + while True: + now = datetime.now() + angle = now.second * 6 + draw_hand(hand_turtle, 180, angle, "red", 2) + time.sleep(0.1) + +def update_minute_hand(hand_turtle): + while True: + now = datetime.now() + angle = now.minute * 6 + now.second * 0.1 + draw_hand(hand_turtle, 150, angle, "black", 4) + time.sleep(0.5) + +def update_hour_hand(hand_turtle): + while True: + now = datetime.now() + angle = (now.hour % 12) * 30 + now.minute * 0.5 + draw_hand(hand_turtle, 100, angle, "black", 6) + time.sleep(1) + +def main(): + screen = setup_screen() + clock_turtle = turtle.Turtle() + clock_turtle.hideturtle() + clock_turtle.speed(0) + draw_clock_face(clock_turtle) + draw_ampm_indicator(clock_turtle) + + # Create turtles for hands + sec_turtle = turtle.Turtle() + sec_turtle.hideturtle() + sec_turtle.speed(0) + min_turtle = turtle.Turtle() + min_turtle.hideturtle() + min_turtle.speed(0) + hour_turtle = turtle.Turtle() + hour_turtle.hideturtle() + hour_turtle.speed(0) + + # Start threads + threading.Thread(target=update_second_hand, args=(sec_turtle,), daemon=True).start() + threading.Thread(target=update_minute_hand, args=(min_turtle,), daemon=True).start() + threading.Thread(target=update_hour_hand, args=(hour_turtle,), daemon=True).start() + + # Update AM/PM indicator every minute + def update_ampm(): + while True: + clock_turtle.clear() + draw_clock_face(clock_turtle) + draw_ampm_indicator(clock_turtle) + time.sleep(60) + threading.Thread(target=update_ampm, daemon=True).start() + + while True: + screen.update() + time.sleep(0.05) + +if __name__ == "__main__": + main() diff --git a/Calendar_Generator_YearWise/README.md b/Calendar_Generator_YearWise/README.md new file mode 100644 index 0000000..b229511 --- /dev/null +++ b/Calendar_Generator_YearWise/README.md @@ -0,0 +1,28 @@ +# Calendar Generator YearWise + +A simple GUI calendar application built with Python and Tkinter that displays the calendar for any given year. + +## Features +- User-friendly interface +- Displays full year calendar in a clean format +- Responsive design +- Easy year input +- Error handling for invalid input + +## Usage +1. Run `calendar_app.py`. +2. Enter a year in the input field. +3. Click "Show Calendar" to display the calendar for the entered year. +4. Use the "Exit" button to close the application. + +## Requirements +- Python 3.x +- Tkinter (usually included with Python) + +## Customization +- Change colors by modifying the `bg` parameters. +- Change fonts by editing the `font` parameters. +- Adjust window sizes via the `geometry` values. + +## License +MIT diff --git a/Calendar_Generator_YearWise/calendar_app.py b/Calendar_Generator_YearWise/calendar_app.py new file mode 100644 index 0000000..0e81248 --- /dev/null +++ b/Calendar_Generator_YearWise/calendar_app.py @@ -0,0 +1,47 @@ +""" +Calendar Generator YearWise +Issue #106 for king04aman/All-In-One-Python-Projects +""" +import tkinter as tk +from tkinter import messagebox +import calendar + +class CalendarApp: + def __init__(self, root): + self.root = root + self.root.title("Yearly Calendar Generator") + self.root.geometry("350x150") + self.root.resizable(False, False) + self.root.configure(bg="#f0f0f0") + + tk.Label(root, text="Enter Year:", font=("Arial", 12), bg="#f0f0f0").pack(pady=10) + self.year_entry = tk.Entry(root, font=("Arial", 12), width=15) + self.year_entry.pack(pady=5) + + tk.Button(root, text="Show Calendar", command=self.show_calendar, font=("Arial", 12), bg="#4caf50", fg="white").pack(pady=10) + tk.Button(root, text="Exit", command=root.quit, font=("Arial", 12), bg="#f44336", fg="white").pack() + + def show_calendar(self): + year = self.year_entry.get() + if not year.isdigit() or int(year) < 1: + messagebox.showerror("Invalid Input", "Please enter a valid positive year.") + return + year = int(year) + cal = calendar.TextCalendar(calendar.SUNDAY) + cal_str = cal.formatyear(year, 2, 1, 1, 3) + self.display_calendar(year, cal_str) + + def display_calendar(self, year, cal_str): + cal_win = tk.Toplevel(self.root) + cal_win.title(f"Calendar for {year}") + cal_win.geometry("600x600") + cal_win.configure(bg="#e3f2fd") + text = tk.Text(cal_win, font=("Consolas", 10), bg="#e3f2fd", fg="#212121") + text.insert(tk.END, cal_str) + text.pack(expand=True, fill=tk.BOTH) + tk.Button(cal_win, text="Close", command=cal_win.destroy, font=("Arial", 12), bg="#1976d2", fg="white").pack(pady=10) + +if __name__ == "__main__": + root = tk.Tk() + app = CalendarApp(root) + root.mainloop() diff --git a/GraphRAG/README.md b/GraphRAG/README.md new file mode 100644 index 0000000..ea5b79b --- /dev/null +++ b/GraphRAG/README.md @@ -0,0 +1,26 @@ +# GraphRAG + +GraphRAG implementation using Llama-Index and NetworkX. + +## Features +- Builds a knowledge graph from documents +- Indexes data points in the graph +- Retrieves and generates contextually relevant responses using an LLM +- Visualizes the knowledge graph + +## Usage +1. Install dependencies: + ```bash + pip install llama-index networkx + ``` +2. Run `graphrag.py`. +3. Example query and knowledge graph visualization will be generated. + +## Requirements +- Python 3.x +- llama-index +- networkx +- OpenAI API key (for LLM and embeddings) + +## License +MIT diff --git a/GraphRAG/graphrag.py b/GraphRAG/graphrag.py new file mode 100644 index 0000000..387b9fa --- /dev/null +++ b/GraphRAG/graphrag.py @@ -0,0 +1,42 @@ +""" +GraphRAG Implementation using Llama-Index and NetworkX +Issue #103 for king04aman/All-In-One-Python-Projects +""" +import networkx as nx +from llama_index.core import KnowledgeGraphIndex, SimpleNodeParser, QueryEngine +from llama_index.llms.openai import OpenAI +from llama_index.embeddings.openai import OpenAIEmbedding + +# Example documents +DOCUMENTS = [ + "Alice is a data scientist. She works at Acme Corp.", + "Bob is a software engineer. He collaborates with Alice on ML projects.", + "Acme Corp is a tech company based in New York." +] + +# Step 1: Parse documents into nodes +parser = SimpleNodeParser() +nodes = parser.get_nodes_from_documents(DOCUMENTS) + +# Step 2: Build Knowledge Graph Index +kg_index = KnowledgeGraphIndex(nodes) + +# Step 3: Create Query Engine (using OpenAI LLM and embeddings) +llm = OpenAI(model="gpt-3.5-turbo") +embed_model = OpenAIEmbedding(model="text-embedding-ada-002") +query_engine = QueryEngine(kg_index, llm=llm, embed_model=embed_model) + +# Step 4: Example query +query = "Who works at Acme Corp?" +response = query_engine.query(query) +print("Query:", query) +print("Response:", response) + +# Step 5: Visualize Knowledge Graph +G = nx.Graph() +for node in nodes: + for rel in node.relationships: + G.add_edge(node.entity, rel.entity, label=rel.type) + +nx.write_gml(G, "knowledge_graph.gml") +print("Knowledge graph saved as knowledge_graph.gml") diff --git a/GraphRAG/requirements.txt b/GraphRAG/requirements.txt new file mode 100644 index 0000000..c67f101 --- /dev/null +++ b/GraphRAG/requirements.txt @@ -0,0 +1,2 @@ +llama-index +networkx diff --git a/Language_Learning_Chatbot/README.md b/Language_Learning_Chatbot/README.md new file mode 100644 index 0000000..69c4861 --- /dev/null +++ b/Language_Learning_Chatbot/README.md @@ -0,0 +1,30 @@ +# Language Learning Chatbot + +A conversational AI language learning companion using OpenAI API. + +## Features +- Chatbot for language practice and learning +- Personalized feedback + +## Usage +1. Install dependencies: + ```bash + pip install flask openai + ``` +2. Set your OpenAI API key as an environment variable: + ```bash + export OPENAI_API_KEY=sk-... + ``` +3. Run the Flask app: + ```bash + python app.py + ``` +4. Open your browser at `http://localhost:5000`. + +## Requirements +- Python 3.x +- Flask +- OpenAI API key + +## License +MIT diff --git a/Language_Learning_Chatbot/app.py b/Language_Learning_Chatbot/app.py new file mode 100644 index 0000000..cbd7bc4 --- /dev/null +++ b/Language_Learning_Chatbot/app.py @@ -0,0 +1,30 @@ +""" +Language Learning Chatbot (Issue #90) +Minimal Flask backend + HTML/JS frontend using OpenAI API +""" +from flask import Flask, request, jsonify, send_from_directory +import os +import openai + +app = Flask(__name__) +openai.api_key = os.getenv("OPENAI_API_KEY", "sk-...") # Replace with your key or set as env var + +@app.route("/api/chat", methods=["POST"]) +def chat(): + user_msg = request.json.get("message", "") + prompt = f"You are a helpful language learning assistant. Help the user practice and learn languages.\nUser: {user_msg}\nAI:" + response = openai.Completion.create( + engine="text-davinci-003", + prompt=prompt, + max_tokens=100, + temperature=0.7 + ) + reply = response.choices[0].text.strip() + return jsonify({"reply": reply}) + +@app.route("/") +def index(): + return send_from_directory(".", "chatbot.html") + +if __name__ == "__main__": + app.run(debug=True) diff --git a/Language_Learning_Chatbot/chatbot.html b/Language_Learning_Chatbot/chatbot.html new file mode 100644 index 0000000..ce56a63 --- /dev/null +++ b/Language_Learning_Chatbot/chatbot.html @@ -0,0 +1,40 @@ + + + + + Language Learning Chatbot + + + +
+

Language Learning Chatbot

+
+ + +
+ + + diff --git a/Language_Learning_Chatbot/requirements.txt b/Language_Learning_Chatbot/requirements.txt new file mode 100644 index 0000000..ee5a708 --- /dev/null +++ b/Language_Learning_Chatbot/requirements.txt @@ -0,0 +1,2 @@ +flask +openai diff --git a/Personal_Finance_Dashboard/README.md b/Personal_Finance_Dashboard/README.md new file mode 100644 index 0000000..ede3360 --- /dev/null +++ b/Personal_Finance_Dashboard/README.md @@ -0,0 +1,26 @@ +# Personal Finance Dashboard + +A simple personal finance dashboard to track expenses, set budgets, and visualize spending habits. + +## Features +- Add and view expenses +- Set and display budget +- Visualize expenses with Chart.js + +## Usage +1. Install dependencies: + ```bash + pip install flask + ``` +2. Run the Flask app: + ```bash + python app.py + ``` +3. Open your browser at `http://localhost:5000`. + +## Requirements +- Python 3.x +- Flask + +## License +MIT diff --git a/Personal_Finance_Dashboard/app.py b/Personal_Finance_Dashboard/app.py new file mode 100644 index 0000000..49bc936 --- /dev/null +++ b/Personal_Finance_Dashboard/app.py @@ -0,0 +1,35 @@ +""" +Personal Finance Dashboard (Issue #93) +Minimal Flask backend + HTML/JS frontend with Chart.js +""" +from flask import Flask, request, jsonify, send_from_directory +import os + +app = Flask(__name__) + +DATA = { + "expenses": [], + "budget": 0 +} + +@app.route("/api/expenses", methods=["GET", "POST"]) +def expenses(): + if request.method == "POST": + expense = request.json + DATA["expenses"].append(expense) + return jsonify({"status": "added"}), 201 + return jsonify(DATA["expenses"]) + +@app.route("/api/budget", methods=["GET", "POST"]) +def budget(): + if request.method == "POST": + DATA["budget"] = request.json.get("budget", 0) + return jsonify({"status": "set"}), 201 + return jsonify({"budget": DATA["budget"]}) + +@app.route("/") +def index(): + return send_from_directory(".", "dashboard.html") + +if __name__ == "__main__": + app.run(debug=True) diff --git a/Personal_Finance_Dashboard/dashboard.html b/Personal_Finance_Dashboard/dashboard.html new file mode 100644 index 0000000..455a118 --- /dev/null +++ b/Personal_Finance_Dashboard/dashboard.html @@ -0,0 +1,82 @@ + + + + + Personal Finance Dashboard + + + + +
+

Personal Finance Dashboard

+
+ + + + +
+
+ + + + +
+ +
+ + + diff --git a/Personal_Finance_Dashboard/requirements.txt b/Personal_Finance_Dashboard/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/Personal_Finance_Dashboard/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/Photo_Organizer_App/README.md b/Photo_Organizer_App/README.md new file mode 100644 index 0000000..f8e4ad6 --- /dev/null +++ b/Photo_Organizer_App/README.md @@ -0,0 +1,27 @@ +# Photo Organizer App + +A simple application to help users organize their photos by date, location, or tags. Users can upload, sort, and search for images easily. + +## Features +- Upload photos with tags +- Search photos by tag or date +- View photo gallery + +## Usage +1. Install dependencies: + ```bash + pip install flask werkzeug + ``` +2. Run the Flask app: + ```bash + python app.py + ``` +3. Open your browser at `http://localhost:5000`. + +## Requirements +- Python 3.x +- Flask +- Werkzeug + +## License +MIT diff --git a/Photo_Organizer_App/app.py b/Photo_Organizer_App/app.py new file mode 100644 index 0000000..93c980c --- /dev/null +++ b/Photo_Organizer_App/app.py @@ -0,0 +1,52 @@ +""" +Photo Organizer App (Issue #89) +Minimal Flask backend + HTML/JS frontend +""" +from flask import Flask, request, jsonify, send_from_directory, render_template_string +import os +from werkzeug.utils import secure_filename +from datetime import datetime + +app = Flask(__name__) +UPLOAD_FOLDER = "photos" +app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER +os.makedirs(UPLOAD_FOLDER, exist_ok=True) + +PHOTOS = [] + +@app.route("/api/upload", methods=["POST"]) +def upload(): + file = request.files['photo'] + tags = request.form.get('tags', '') + filename = secure_filename(file.filename) + filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename) + file.save(filepath) + meta = { + "filename": filename, + "date": datetime.now().strftime('%Y-%m-%d'), + "tags": tags.split(',') if tags else [] + } + PHOTOS.append(meta) + return jsonify({"status": "uploaded"}) + +@app.route("/api/photos", methods=["GET"]) +def get_photos(): + tag = request.args.get('tag') + date = request.args.get('date') + results = PHOTOS + if tag: + results = [p for p in results if tag in p['tags']] + if date: + results = [p for p in results if p['date'] == date] + return jsonify(results) + +@app.route("/photos/") +def serve_photo(filename): + return send_from_directory(app.config['UPLOAD_FOLDER'], filename) + +@app.route("/") +def index(): + return send_from_directory(".", "organizer.html") + +if __name__ == "__main__": + app.run(debug=True) diff --git a/Photo_Organizer_App/organizer.html b/Photo_Organizer_App/organizer.html new file mode 100644 index 0000000..afd82f1 --- /dev/null +++ b/Photo_Organizer_App/organizer.html @@ -0,0 +1,54 @@ + + + + + Photo Organizer App + + + +
+

Photo Organizer App

+
+ + + +
+
+ + + + + +
+
+
+ + + diff --git a/Photo_Organizer_App/requirements.txt b/Photo_Organizer_App/requirements.txt new file mode 100644 index 0000000..253aebd --- /dev/null +++ b/Photo_Organizer_App/requirements.txt @@ -0,0 +1,2 @@ +flask +werkzeug diff --git a/Simple_PDF_Editor/README.md b/Simple_PDF_Editor/README.md new file mode 100644 index 0000000..adbbe5f --- /dev/null +++ b/Simple_PDF_Editor/README.md @@ -0,0 +1,26 @@ +# Simple PDF Editor + +A Python script using PyPDF2 and reportlab to edit PDF files. Supports text and image insertion. + +## Features +- Insert text into PDF files +- Insert images into PDF files + +## Usage +1. Install dependencies: + ```bash + pip install PyPDF2 reportlab + ``` +2. Use the functions in `pdf_editor.py`: + ```python + insert_text("input.pdf", "output_text.pdf", "Hello PDF!", 100, 700) + insert_image("input.pdf", "output_image.pdf", "image.jpg", 100, 500, 200, 150) + ``` + +## Requirements +- Python 3.x +- PyPDF2 +- reportlab + +## License +MIT diff --git a/Simple_PDF_Editor/pdf_editor.py b/Simple_PDF_Editor/pdf_editor.py new file mode 100644 index 0000000..2aaa7d3 --- /dev/null +++ b/Simple_PDF_Editor/pdf_editor.py @@ -0,0 +1,50 @@ +""" +Simple PDF Editor using PyPDF2 and reportlab +Issue #37 for king04aman/All-In-One-Python-Projects +""" +import PyPDF2 +from reportlab.pdfgen import canvas +from reportlab.lib.pagesizes import letter +import io + +# Insert text into a PDF (creates a new PDF with text overlay) +def insert_text(input_pdf, output_pdf, text, x=100, y=700): + packet = io.BytesIO() + can = canvas.Canvas(packet, pagesize=letter) + can.drawString(x, y, text) + can.save() + packet.seek(0) + new_pdf = PyPDF2.PdfReader(packet) + existing_pdf = PyPDF2.PdfReader(open(input_pdf, "rb")) + writer = PyPDF2.PdfWriter() + page = existing_pdf.pages[0] + page.merge_page(new_pdf.pages[0]) + writer.add_page(page) + for p in existing_pdf.pages[1:]: + writer.add_page(p) + with open(output_pdf, "wb") as f: + writer.write(f) + +# Insert image into a PDF (creates a new PDF with image overlay) +def insert_image(input_pdf, output_pdf, image_path, x=100, y=500, w=200, h=150): + packet = io.BytesIO() + can = canvas.Canvas(packet, pagesize=letter) + can.drawImage(image_path, x, y, width=w, height=h) + can.save() + packet.seek(0) + new_pdf = PyPDF2.PdfReader(packet) + existing_pdf = PyPDF2.PdfReader(open(input_pdf, "rb")) + writer = PyPDF2.PdfWriter() + page = existing_pdf.pages[0] + page.merge_page(new_pdf.pages[0]) + writer.add_page(page) + for p in existing_pdf.pages[1:]: + writer.add_page(p) + with open(output_pdf, "wb") as f: + writer.write(f) + +if __name__ == "__main__": + # Example usage + # insert_text("input.pdf", "output_text.pdf", "Hello PDF!", 100, 700) + # insert_image("input.pdf", "output_image.pdf", "image.jpg", 100, 500, 200, 150) + print("Simple PDF Editor ready. Uncomment example usage to test.") diff --git a/Simple_PDF_Editor/requirements.txt b/Simple_PDF_Editor/requirements.txt new file mode 100644 index 0000000..0628811 --- /dev/null +++ b/Simple_PDF_Editor/requirements.txt @@ -0,0 +1,2 @@ +PyPDF2 +reportlab diff --git a/Student_Management_System/README.md b/Student_Management_System/README.md new file mode 100644 index 0000000..e3432e6 --- /dev/null +++ b/Student_Management_System/README.md @@ -0,0 +1,39 @@ +# Student Management System + +A complete GUI-based Student Management System built with Python. + +## Features +- Add new students with automated roll number assignment +- Update student information (address, date of birth) +- Delete student records +- Search by roll number or name +- Secure login interface for administrators only + +## Technologies Used +- Python +- Tkinter (GUI) +- Pandas, Numpy (data storage and logic) + +## Usage +1. Run `main.py`. +2. Login with username: `admin`, password: `password` (default, can be changed in code). +3. Use the GUI to manage student records. + +## Data Storage +Student data is stored in `students.csv` in the same directory. + +## Requirements +- Python 3.x +- pandas +- numpy + +Install dependencies: +```bash +pip install pandas numpy +``` + +## Customization +- Change admin credentials in `main.py` (`ADMIN_USER`, `ADMIN_PASS`). + +## License +MIT diff --git a/Student_Management_System/main.py b/Student_Management_System/main.py new file mode 100644 index 0000000..7791f0b --- /dev/null +++ b/Student_Management_System/main.py @@ -0,0 +1,118 @@ +""" +Student Management System +GUI-based application for managing student records. +Modules: tkinter, pandas, numpy, time +""" + +import tkinter as tk +from tkinter import messagebox, simpledialog +import pandas as pd +import numpy as np +import time +import os + +DATA_FILE = "students.csv" +ADMIN_USER = "admin" +ADMIN_PASS = "password" + +# Initialize data file if not exists +def init_data_file(): + if not os.path.exists(DATA_FILE): + df = pd.DataFrame(columns=["Roll", "Name", "Address", "DOB"]) + df.to_csv(DATA_FILE, index=False) + +# Login Window +def login_window(): + login = tk.Tk() + login.title("Admin Login") + login.geometry("300x150") + + tk.Label(login, text="Username:").pack() + username_entry = tk.Entry(login) + username_entry.pack() + tk.Label(login, text="Password:").pack() + password_entry = tk.Entry(login, show="*") + password_entry.pack() + + def check_login(): + user = username_entry.get() + pwd = password_entry.get() + if user == ADMIN_USER and pwd == ADMIN_PASS: + login.destroy() + main_window() + else: + messagebox.showerror("Login Failed", "Invalid credentials!") + + tk.Button(login, text="Login", command=check_login).pack(pady=10) + login.mainloop() + +# Main Window +def main_window(): + root = tk.Tk() + root.title("Student Management System") + root.geometry("400x400") + + def add_student(): + df = pd.read_csv(DATA_FILE) + name = simpledialog.askstring("Add Student", "Enter Name:") + address = simpledialog.askstring("Add Student", "Enter Address:") + dob = simpledialog.askstring("Add Student", "Enter DOB (YYYY-MM-DD):") + roll = int(df["Roll"].max()) + 1 if not df.empty else 1 + df = df.append({"Roll": roll, "Name": name, "Address": address, "DOB": dob}, ignore_index=True) + df.to_csv(DATA_FILE, index=False) + messagebox.showinfo("Success", f"Student added with Roll No: {roll}") + + def update_student(): + df = pd.read_csv(DATA_FILE) + roll = simpledialog.askinteger("Update Student", "Enter Roll No:") + if roll in df["Roll"].values: + idx = df.index[df["Roll"] == roll][0] + name = simpledialog.askstring("Update Student", "Enter New Name:") + address = simpledialog.askstring("Update Student", "Enter New Address:") + dob = simpledialog.askstring("Update Student", "Enter New DOB (YYYY-MM-DD):") + df.at[idx, "Name"] = name + df.at[idx, "Address"] = address + df.at[idx, "DOB"] = dob + df.to_csv(DATA_FILE, index=False) + messagebox.showinfo("Success", "Student info updated!") + else: + messagebox.showerror("Error", "Roll No not found!") + + def delete_student(): + df = pd.read_csv(DATA_FILE) + roll = simpledialog.askinteger("Delete Student", "Enter Roll No:") + if roll in df["Roll"].values: + df = df[df["Roll"] != roll] + df.to_csv(DATA_FILE, index=False) + messagebox.showinfo("Success", "Student deleted!") + else: + messagebox.showerror("Error", "Roll No not found!") + + def search_student(): + df = pd.read_csv(DATA_FILE) + search_by = simpledialog.askstring("Search Student", "Search by 'roll' or 'name':") + if search_by == "roll": + roll = simpledialog.askinteger("Search Student", "Enter Roll No:") + result = df[df["Roll"] == roll] + elif search_by == "name": + name = simpledialog.askstring("Search Student", "Enter Name:") + result = df[df["Name"].str.lower() == name.lower()] + else: + messagebox.showerror("Error", "Invalid search type!") + return + if not result.empty: + info = result.to_string(index=False) + messagebox.showinfo("Student Found", info) + else: + messagebox.showinfo("Not Found", "No student found!") + + tk.Button(root, text="Add Student", command=add_student, width=25).pack(pady=10) + tk.Button(root, text="Update Student", command=update_student, width=25).pack(pady=10) + tk.Button(root, text="Delete Student", command=delete_student, width=25).pack(pady=10) + tk.Button(root, text="Search Student", command=search_student, width=25).pack(pady=10) + tk.Button(root, text="Exit", command=root.destroy, width=25).pack(pady=10) + root.mainloop() + +if __name__ == "__main__": + init_data_file() + login_window() diff --git a/Student_Management_System/requirements.txt b/Student_Management_System/requirements.txt new file mode 100644 index 0000000..9dff893 --- /dev/null +++ b/Student_Management_System/requirements.txt @@ -0,0 +1,2 @@ +pandas +numpy diff --git a/Sustainable_Travel_Planner/README.md b/Sustainable_Travel_Planner/README.md new file mode 100644 index 0000000..2bca7c4 --- /dev/null +++ b/Sustainable_Travel_Planner/README.md @@ -0,0 +1,25 @@ +# Sustainable Travel Planner + +A simple sustainable travel planning application to promote eco-friendly travel, reduce carbon footprint, and support local communities. + +## Features +- Suggests eco-friendly destinations and activities +- Displays eco score for each suggestion + +## Usage +1. Install dependencies: + ```bash + pip install flask + ``` +2. Run the Flask app: + ```bash + python app.py + ``` +3. Open your browser at `http://localhost:5000`. + +## Requirements +- Python 3.x +- Flask + +## License +MIT diff --git a/Sustainable_Travel_Planner/app.py b/Sustainable_Travel_Planner/app.py new file mode 100644 index 0000000..f927926 --- /dev/null +++ b/Sustainable_Travel_Planner/app.py @@ -0,0 +1,27 @@ +""" +Sustainable Travel Planner (Issue #91) +Minimal Flask backend + HTML/JS frontend +""" +from flask import Flask, request, jsonify, send_from_directory +import os + +app = Flask(__name__) + +SUGGESTIONS = [ + {"destination": "Amsterdam", "activity": "Bike tours, local markets", "eco_score": 9}, + {"destination": "Costa Rica", "activity": "Rainforest hikes, eco-lodges", "eco_score": 10}, + {"destination": "Kyoto", "activity": "Temple visits, public transport", "eco_score": 8}, + {"destination": "Vancouver", "activity": "Urban parks, cycling", "eco_score": 8}, + {"destination": "New Zealand", "activity": "Nature reserves, local farms", "eco_score": 9} +] + +@app.route("/api/suggestions", methods=["GET"]) +def suggestions(): + return jsonify(SUGGESTIONS) + +@app.route("/") +def index(): + return send_from_directory(".", "sustainable.html") + +if __name__ == "__main__": + app.run(debug=True) diff --git a/Sustainable_Travel_Planner/requirements.txt b/Sustainable_Travel_Planner/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/Sustainable_Travel_Planner/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/Sustainable_Travel_Planner/sustainable.html b/Sustainable_Travel_Planner/sustainable.html new file mode 100644 index 0000000..95ae452 --- /dev/null +++ b/Sustainable_Travel_Planner/sustainable.html @@ -0,0 +1,43 @@ + + + + + Sustainable Travel Planner + + + +
+

Sustainable Travel Planner

+

Discover eco-friendly destinations and activities to reduce your carbon footprint and support local communities.

+ + + + + + + + + +
DestinationActivityEco Score
+
+ + + diff --git a/Travel_Itinerary_Planner/README.md b/Travel_Itinerary_Planner/README.md new file mode 100644 index 0000000..98ab67e --- /dev/null +++ b/Travel_Itinerary_Planner/README.md @@ -0,0 +1,28 @@ +# Travel Itinerary Planner + +A simple travel itinerary planner to create, save, and share travel plans including places to visit, accommodations, and activities. + +## Features +- Add and view itineraries +- Map preview for places to visit (Google Maps embed) +- Save trip details + +## Usage +1. Install dependencies: + ```bash + pip install flask + ``` +2. Run the Flask app: + ```bash + python app.py + ``` +3. Open your browser at `http://localhost:5000`. +4. For map preview, replace `YOUR_API_KEY` in `planner.html` with your Google Maps Embed API key. + +## Requirements +- Python 3.x +- Flask +- Google Maps Embed API key (for map preview) + +## License +MIT diff --git a/Travel_Itinerary_Planner/app.py b/Travel_Itinerary_Planner/app.py new file mode 100644 index 0000000..57e9ef6 --- /dev/null +++ b/Travel_Itinerary_Planner/app.py @@ -0,0 +1,25 @@ +""" +Travel Itinerary Planner (Issue #92) +Minimal Flask backend + HTML/JS frontend with Google Maps embed +""" +from flask import Flask, request, jsonify, send_from_directory +import os + +app = Flask(__name__) + +ITINERARIES = [] + +@app.route("/api/itineraries", methods=["GET", "POST"]) +def itineraries(): + if request.method == "POST": + itinerary = request.json + ITINERARIES.append(itinerary) + return jsonify({"status": "added"}), 201 + return jsonify(ITINERARIES) + +@app.route("/") +def index(): + return send_from_directory(".", "planner.html") + +if __name__ == "__main__": + app.run(debug=True) diff --git a/Travel_Itinerary_Planner/planner.html b/Travel_Itinerary_Planner/planner.html new file mode 100644 index 0000000..11f2d73 --- /dev/null +++ b/Travel_Itinerary_Planner/planner.html @@ -0,0 +1,71 @@ + + + + + Travel Itinerary Planner + + + +
+

Travel Itinerary Planner

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +

Saved Itineraries

+ +

Map Preview

+ +
+ + + diff --git a/Travel_Itinerary_Planner/requirements.txt b/Travel_Itinerary_Planner/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/Travel_Itinerary_Planner/requirements.txt @@ -0,0 +1 @@ +flask