diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml index 68fdd1e1a..6a78320cf 100644 --- a/.github/workflows/jekyll-gh-pages.yml +++ b/.github/workflows/jekyll-gh-pages.yml @@ -42,7 +42,7 @@ jobs: source: ./ destination: ./_site - name: Upload artifact - uses: actions/upload-pages-artifact@v1 + uses: actions/upload-pages-artifact@v3 # Deployment job deploy: @@ -54,4 +54,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v4 diff --git a/Gemfile b/Gemfile index 68d10849f..186c6c1f2 100644 --- a/Gemfile +++ b/Gemfile @@ -4,4 +4,7 @@ gem "github-pages", group: :jekyll_plugins gem "webrick", "~> 1.7" -gem "execjs", "~> 2.8" \ No newline at end of file +gem "execjs", "~> 2.8" + +gem "jekyll-remote-theme" + diff --git a/Makefile b/Makefile index 7d9cdaf86..320ff99d3 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Configuration, override port with usage: make PORT=4200 PORT ?= 4100 -REPO_NAME ?= student_2025 +REPO_NAME ?= yash1_2025 LOG_FILE = /tmp/jekyll$(PORT).log SHELL = /bin/bash -c diff --git a/_config.yml b/_config.yml index 4f8d1eb3b..b8fefe285 100644 --- a/_config.yml +++ b/_config.yml @@ -1,11 +1,12 @@ -title: Nighthawk Pages +title: Yash's Pages description: "Class of 2025" owner_name: John Mortensen github_username: nighthawkcoders -github_repo: "student_2025" -baseurl: "/student_2025" +github_repo: "yash1_2025" +baseurl: "/yash1_2025" + future: true -remote_theme: jekyll/minima +remote_theme: pages-themes/cayman@v0.2.0 minima: skin: dark social_links: @@ -20,7 +21,11 @@ minima: plugins: - jekyll-remote-theme header_pages: + - navigation/liverpool.md - navigation/blog.md - navigation/search.md - navigation/about.md + - navigation/journey.md - README4YML.md + + diff --git a/_notebooks/2024-12-02-python-flask_in_jupyter.ipynb b/_notebooks/2024-12-02-python-flask_in_jupyter.ipynb new file mode 100644 index 000000000..3e1b7cd20 --- /dev/null +++ b/_notebooks/2024-12-02-python-flask_in_jupyter.ipynb @@ -0,0 +1,695 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "---\n", + "toc: true\n", + "comments: false\n", + "layout: post\n", + "title: BI 4.1 Internet - Web Server \n", + "description: Quick launch into Flask, sending and receiving data from a web server.\n", + "courses: { csp: {week: 14 } }\n", + "type: ccc\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Introduction\n", + "\n", + "Welcome to this journey into the world of web servers and the Flask framework! In the previous weeks, you've successfully set up a web server using GitHub Pages, converting Jupyter Notebooks into Markdown for a seamless online presentation. Today, we'll take that knowledge to the next level as we dive into creating your very own web server using Flask.\n", + "\n", + "### Understanding Web Servers\n", + "What is a Web Server?\n", + "\n", + "Traditionally, we had librarians at libraries that would help you find books or information. Today in the digital world, thousands upon thousands of home pages, search engines, and digital archives have been built using web servers.\n", + "\n", + "### GitHub Pages vs. Flask\n", + "\n", + "You've already experienced a form of web server through GitHub Pages. Think of GitHub Pages as a library that has established rules for publishing Markdown notes and Jupyter Notebooks neatly on a bookshelf.\n", + "\n", + "Now, let's introduce Flask, your personal web server. Flask can create and manage any type of content, including customizing everything according to your preferences, and even serve additional information (like a database with APIs).\n", + "\n", + "The Flask Framework\n", + "Flask is a micro web framework written in Python. It's designed to be minimal and easy to use, making it perfect for building web applications, APIs, and, yes, even your web server. Today, we will start with the basics of Flask and see how it empowers you to create and manage web content." + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Our Goals for Today\n", + "Here's what we'll accomplish in this session:\n", + "\n", + "- Create a minimal Flask server.\n", + "- Explore the Python/Flask process.\n", + "- Access data from our Flask server using Python.\n", + "- Access data from our Flask server using JavaScript.\n", + "- Learn how to stop the Python/Flask process gracefully.\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Install required libraries\n", + "These libraries are required to run and interact with the Python web server." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting flask\n", + " Using cached flask-3.1.0-py3-none-any.whl (102 kB)\n", + "Collecting flask-cors\n", + " Using cached Flask_Cors-5.0.0-py2.py3-none-any.whl (14 kB)\n", + "Requirement already satisfied: requests in /home/yashpatil/nighthawk/yash1_2025/venv/lib/python3.10/site-packages (2.32.3)\n", + "Collecting blinker>=1.9\n", + " Using cached blinker-1.9.0-py3-none-any.whl (8.5 kB)\n", + "Requirement already satisfied: Jinja2>=3.1.2 in /home/yashpatil/nighthawk/yash1_2025/venv/lib/python3.10/site-packages (from flask) (3.1.4)\n", + "Collecting Werkzeug>=3.1\n", + " Using cached werkzeug-3.1.3-py3-none-any.whl (224 kB)\n", + "Collecting itsdangerous>=2.2\n", + " Using cached itsdangerous-2.2.0-py3-none-any.whl (16 kB)\n", + "Collecting click>=8.1.3\n", + " Using cached click-8.1.7-py3-none-any.whl (97 kB)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/yashpatil/nighthawk/yash1_2025/venv/lib/python3.10/site-packages (from requests) (2024.8.30)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /home/yashpatil/nighthawk/yash1_2025/venv/lib/python3.10/site-packages (from requests) (3.4.0)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/yashpatil/nighthawk/yash1_2025/venv/lib/python3.10/site-packages (from requests) (2.2.3)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/yashpatil/nighthawk/yash1_2025/venv/lib/python3.10/site-packages (from requests) (3.10)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /home/yashpatil/nighthawk/yash1_2025/venv/lib/python3.10/site-packages (from Jinja2>=3.1.2->flask) (3.0.2)\n", + "Installing collected packages: Werkzeug, itsdangerous, click, blinker, flask, flask-cors\n", + "Successfully installed Werkzeug-3.1.3 blinker-1.9.0 click-8.1.7 flask-3.1.0 flask-cors-5.0.0 itsdangerous-2.2.0\n" + ] + } + ], + "source": [ + "!pip install flask flask-cors requests" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Start Web Server\n", + "This Python code provides a simple server with an accessible API.\n", + "\n", + "Note: Jupyter magic commmand `%%python --bg` that follows runs the server in background. This enables us to continue interacting with the subsequent Notebook cells." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "%%python --bg\n", + "\n", + "from flask import Flask, jsonify\n", + "from flask_cors import CORS\n", + "\n", + "# initialize a flask application (app)\n", + "app = Flask(__name__)\n", + "CORS(app, supports_credentials=True, origins='*') # Allow all origins (*)\n", + "\n", + "# ... your existing Flask\n", + "\n", + "# add an api endpoint to flask app\n", + "@app.route('/api/data')\n", + "def get_data():\n", + " # start a list, to be used like a information database\n", + " InfoDb = []\n", + "\n", + " # add a row to list, an Info record\n", + " InfoDb.append({\n", + " \"FirstName\": \"John\",\n", + " \"LastName\": \"Mortensen\",\n", + " \"DOB\": \"October 21\",\n", + " \"Residence\": \"San Diego\",\n", + " \"Email\": \"jmortensen@powayusd.com\",\n", + " \"Owns_Cars\": [\"2015-Fusion\", \"2011-Ranger\", \"2003-Excursion\", \"1997-F350\", \"1969-Cadillac\"]\n", + " })\n", + "\n", + " # add a row to list, an Info record\n", + " InfoDb.append({\n", + " \"FirstName\": \"Shane\",\n", + " \"LastName\": \"Lopez\",\n", + " \"DOB\": \"February 27\",\n", + " \"Residence\": \"San Diego\",\n", + " \"Email\": \"slopez@powayusd.com\",\n", + " \"Owns_Cars\": [\"2021-Insight\"]\n", + " })\n", + " \n", + " return jsonify(InfoDb)\n", + "\n", + "# add an HTML endpoint to flask app\n", + "@app.route('/')\n", + "def say_hello():\n", + " html_content = \"\"\"\n", + " \n", + " \n", + " Hellox\n", + " \n", + " \n", + "

Hello, World!

\n", + " \n", + " \n", + " \"\"\"\n", + " return html_content\n", + "\n", + "if __name__ == '__main__':\n", + " # starts flask server on default port, http://127.0.0.1:5001\n", + " app.run(port=5001)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Explore the Python/Flask process with Linux\n", + "This script discovers the running flask process on your machine using Linux commands.\n", + "\n", + "1. lsof - list open files\n", + "2. `lsof` and `awk` return the process id, so `ps` can list details, the vericle bar is called a `pipe`. A pipe flows output from one command to the next.\n", + "3. `curl` is a Linux utiltity that is easiest way to test if web server is responding" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "vscode": { + "languageId": "bat" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Python open files on port 5001\n", + "COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME\n", + "python 379334 yashpatil 3u IPv4 3552022 0t0 TCP localhost:5001 (LISTEN)\n", + "\n", + "Python process\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "your 131072x1 screen size is bogus. expect trouble\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + " PID TTY TIME CMD\n", + " 320005 pts/2 00:00:00 sh\n", + " 320006 pts/2 00:00:00 sh\n", + " 320011 pts/2 00:00:00 sh\n", + " 320015 pts/2 00:00:42 node\n", + " 320053 pts/2 00:00:02 node\n", + " 320076 pts/2 00:02:06 node\n", + " 320116 pts/2 00:00:13 node\n", + " 320168 pts/2 00:00:00 pet\n", + " 320445 pts/2 00:00:00 node\n", + " 320568 pts/2 00:00:16 node\n", + " 374664 pts/2 00:00:17 node\n", + " 374715 pts/2 00:00:00 node\n", + " 374727 pts/2 00:00:02 node\n", + " 374788 pts/2 00:00:02 pet\n", + " 375142 pts/2 00:00:21 node\n", + " 379101 pts/2 00:00:00 python\n", + " 379334 pts/2 00:00:00 python\n", + " 379336 pts/2 00:00:00 bash\n", + " 379342 pts/2 00:00:00 xargs\n", + " 379343 pts/2 00:00:00 ps\n", + "\n", + "Content of the Python root endpoint (aka /), using curl,\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + " % Total % Received % Xferd Average Speed Time Time Time Current\n", + " Dload Upload Total Spent Left Speed\n", + "100 135 100 135 0 0 34597 0 --:--:-- --:--:-- --:--:-- 45000\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " \n", + " \n", + " Hellox\n", + " \n", + " \n", + "

Hello, World!

\n", + " \n", + " \n", + " " + ] + } + ], + "source": [ + "%%script bash\n", + "\n", + "# After app.run(), see the the Python open files on port 5001\n", + "echo \"Python open files on port 5001\" \n", + "lsof -i :5001\n", + "# see the the Python process \n", + "echo\n", + "echo \"Python process\"\n", + "lsof -i :5001 | awk '/Python/ {print $2}' | xargs ps\n", + "# show ontent of the Python server using curl\n", + "echo\n", + "echo \"Content of the Python root endpoint (aka /), using curl\", \n", + "curl http://localhost:5001/\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Access data from our Flask server using Python\n", + "The code block below shows alternate ways to access the Web Server.\n", + "1. Import requests and use it to obtain response from endpoints\n", + "2. The response is a Python object that contains status codes and data\n", + "3. The data can be in different forms, we will be focussed on JSON responses in Full-Stack." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Print Status Message: \n", + "\n", + "Print Raw HTML:\n", + " \n", + " \n", + " \n", + " Hellox\n", + " \n", + " \n", + "

Hello, World!

\n", + " \n", + " \n", + " \n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " Hellox\n", + " \n", + " \n", + "

Hello, World!

\n", + " \n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Print Status Message: \n" + ] + } + ], + "source": [ + "import requests\n", + "from IPython.display import HTML, display\n", + "\n", + "# call api root endpoint (aka '/'), often called home page\n", + "response = requests.get('http://127.0.0.1:5001/')\n", + "# output response in different forms\n", + "print(\"Print Status Message:\", response)\n", + "print(\"\\nPrint Raw HTML:\\n\", response.text)\n", + "display(HTML(response.text))\n", + "\n", + "# call unknown api endpoint\n", + "response = requests.get('http://127.0.0.1:5001/unknown-page')\n", + "print(\"Print Status Message:\", response)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[{'DOB': 'October 21',\n", + " 'Email': 'jmortensen@powayusd.com',\n", + " 'FirstName': 'John',\n", + " 'LastName': 'Mortensen',\n", + " 'Owns_Cars': ['2015-Fusion',\n", + " '2011-Ranger',\n", + " '2003-Excursion',\n", + " '1997-F350',\n", + " '1969-Cadillac'],\n", + " 'Residence': 'San Diego'},\n", + " {'DOB': 'February 27',\n", + " 'Email': 'slopez@powayusd.com',\n", + " 'FirstName': 'Shane',\n", + " 'LastName': 'Lopez',\n", + " 'Owns_Cars': ['2021-Insight'],\n", + " 'Residence': 'San Diego'}]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import requests\n", + "# an api endpoint most commonly returns JSON data\n", + "response = requests.get('http://127.0.0.1:5001/api/data')\n", + "response.json()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Access data from our Flask server using JavaScript\n", + "This sample is very similar to Full-Stack as the JavaScript is running through Jupyter and the Web server is a Python Process running on our machine (local server).\n", + "\n", + "1. HTML is used to setup basics of a table\n", + "2. The script block, has javascript fetch that passes endpoint (url) and options. The options are critical to communicating request requirements.\n", + "3. Similar to python examples, data is extracted and that data is written to the document, which is what is viewable to the user as the page is rendered. Headings are static in the document, but rows are dynamically extracted according to the information contained in the server." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "vscode": { + "languageId": "html" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "

Access data from our Flask server using JavaScript

\n", + "\n", + "

This code extracts data \"live\" from a local Web Server with JavaScript fetch. Additionally, it formats the data into a table.

\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
First NameLast NameResidence
\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%%html\n", + "\n", + "

Access data from our Flask server using JavaScript

\n", + "\n", + "

This code extracts data \"live\" from a local Web Server with JavaScript fetch. Additionally, it formats the data into a table.

\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
First NameLast NameResidence
\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Stop the Python/Flask process\n", + "This script ends Python/Flask process using pipes to obtain the python process. Then echo the python process to `kill -9`. " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "vscode": { + "languageId": "bat" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Killing python process with PID: \n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n", + "Usage:\n", + " kill [options] [...]\n", + "\n", + "Options:\n", + " [...] send signal to every listed\n", + " -, -s, --signal \n", + " specify the to be sent\n", + " -q, --queue integer value to be sent with the signal\n", + " -l, --list=[] list all signal names, or convert one to a name\n", + " -L, --table list all signal names in a nice table\n", + "\n", + " -h, --help display this help and exit\n", + " -V, --version output version information and exit\n", + "\n", + "For more details see kill(1).\n" + ] + }, + { + "ename": "CalledProcessError", + "evalue": "Command 'b'\\npython_ps=$(lsof -i :5001 | awk \\'/python/ {print $2}\\')\\necho \"Killing python process with PID: $python_ps\"\\necho $python_ps | xargs kill -9\\n'' returned non-zero exit status 123.", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mCalledProcessError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mget_ipython\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun_cell_magic\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mscript\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mbash\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43mpython_ps=$(lsof -i :5001 | awk \u001b[39;49m\u001b[38;5;130;43;01m\\'\u001b[39;49;00m\u001b[38;5;124;43m/python/ \u001b[39;49m\u001b[38;5;124;43m{\u001b[39;49m\u001b[38;5;124;43mprint $2}\u001b[39;49m\u001b[38;5;130;43;01m\\'\u001b[39;49;00m\u001b[38;5;124;43m)\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43mecho \u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mKilling python process with PID: $python_ps\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43mecho $python_ps | xargs kill -9\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2541\u001b[0m, in \u001b[0;36mInteractiveShell.run_cell_magic\u001b[0;34m(self, magic_name, line, cell)\u001b[0m\n\u001b[1;32m 2539\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbuiltin_trap:\n\u001b[1;32m 2540\u001b[0m args \u001b[38;5;241m=\u001b[39m (magic_arg_s, cell)\n\u001b[0;32m-> 2541\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2543\u001b[0m \u001b[38;5;66;03m# The code below prevents the output from being displayed\u001b[39;00m\n\u001b[1;32m 2544\u001b[0m \u001b[38;5;66;03m# when using magics with decorator @output_can_be_silenced\u001b[39;00m\n\u001b[1;32m 2545\u001b[0m \u001b[38;5;66;03m# when the last Python token in the expression is a ';'.\u001b[39;00m\n\u001b[1;32m 2546\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mgetattr\u001b[39m(fn, magic\u001b[38;5;241m.\u001b[39mMAGIC_OUTPUT_CAN_BE_SILENCED, \u001b[38;5;28;01mFalse\u001b[39;00m):\n", + "File \u001b[0;32m~/.local/lib/python3.10/site-packages/IPython/core/magics/script.py:315\u001b[0m, in \u001b[0;36mScriptMagics.shebang\u001b[0;34m(self, line, cell)\u001b[0m\n\u001b[1;32m 310\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m args\u001b[38;5;241m.\u001b[39mraise_error \u001b[38;5;129;01mand\u001b[39;00m p\u001b[38;5;241m.\u001b[39mreturncode \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m 311\u001b[0m \u001b[38;5;66;03m# If we get here and p.returncode is still None, we must have\u001b[39;00m\n\u001b[1;32m 312\u001b[0m \u001b[38;5;66;03m# killed it but not yet seen its return code. We don't wait for it,\u001b[39;00m\n\u001b[1;32m 313\u001b[0m \u001b[38;5;66;03m# in case it's stuck in uninterruptible sleep. -9 = SIGKILL\u001b[39;00m\n\u001b[1;32m 314\u001b[0m rc \u001b[38;5;241m=\u001b[39m p\u001b[38;5;241m.\u001b[39mreturncode \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m9\u001b[39m\n\u001b[0;32m--> 315\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CalledProcessError(rc, cell)\n", + "\u001b[0;31mCalledProcessError\u001b[0m: Command 'b'\\npython_ps=$(lsof -i :5001 | awk \\'/python/ {print $2}\\')\\necho \"Killing python process with PID: $python_ps\"\\necho $python_ps | xargs kill -9\\n'' returned non-zero exit status 123." + ] + } + ], + "source": [ + "%%script bash\n", + "\n", + "python_ps=$(lsof -i :5001 | awk '/python/ {print $2}')\n", + "echo \"Killing python process with PID: $python_ps\"\n", + "echo $python_ps | xargs kill -9" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Hacks\n", + "Edit, stop and start the web server.\n", + "- Add to the Home Page\n", + "- Add your own information to the Web API\n", + "- Use from Template to start your own Team Flask project https://github.com/nighthawkcoders/flocker_backend" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/2025-01-24-FinalReview.ipynb b/_notebooks/2025-01-24-FinalReview.ipynb new file mode 100644 index 000000000..5c3e1aeba --- /dev/null +++ b/_notebooks/2025-01-24-FinalReview.ipynb @@ -0,0 +1,564 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: Final Review Poseidon Chatbot\n", + "description: Review of all Trimester Two for the neptune Poseidon Chatbot\n", + "comments: true\n", + "sticky_rank: 1\n", + "permalink: /poseidonFinal\n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## 📌 Planning \n", + "Before diving into this trimester with our social media project **Neptune**, I helped my group map out the whole process using burndown lists, figma, and stand up meetings" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "**Important Links**\n", + "\n", + "\n", + "**astronet self-grade issue:** https://github.com/DNHS-Neptune/neptune_frontend/issues/26\n", + "\n", + "**Yash's burndown list:** https://github.com/users/nulxn/projects/2/views/1?pane=issue&itemId=90738734&issue=DNHS-Neptune%7Cneptune_frontend%7C11\n", + "\n", + "**Yash Patil's Posiedon User Story** https://github.com/DNHS-Neptune/neptune_frontend/issues/3\n", + "\n", + "**Figma Designs**\n", + "\n" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## ✅ 5 Things Done Over 12 Weeks \n", + "\n", + "Over the past 12 weeks, I focused on backend UX engineering, database management, and API development, making significant contributions to my project and helping peers. Here are the five key areas I worked on: \n", + "\n", + "### 1️⃣ **Developed & Optimized the Gemini Integration API** \n", + "- Built a **fully functional API** to interface with Gemini AI. \n", + "- Designed **efficient request handling** to optimize response times. \n", + "- Implemented **error handling mechanisms** to improve system stability. \n", + "\n", + "### 2️⃣ **Database Integration & Management** \n", + "- Structured a **database schema** for storing chatbot interactions. \n", + "- Used **SQLAlchemy** to implement and manage CRUD operations. \n", + "- Optimized **data retrieval** to improve backend efficiency. \n", + "\n", + "### 3️⃣ **Backend UX & Administrative Tables** \n", + "- Designed an **intuitive backend UX** to streamline API interactions. \n", + "- Implemented **admin tables** for managing chatbot logs and user interactions. \n", + "- Ensured a **clean and maintainable structure** for easy future updates. \n", + "\n", + "### 4️⃣ **Peer Mentorship & Collaboration** \n", + "- Assisted **8+ classmates** in integrating Gemini AI into their projects. \n", + "- Provided **guidance on debugging, database queries, and API design**. \n", + "- Helped **new students organize final exam materials** and prepare effectively. \n", + "\n", + "### 5️⃣ **AWS Deployment** \n", + "- Researched and planned **AWS deployment strategies** for scalability. \n", + "- Worked on and effectivly **set up cloud-based hosting** to make the chatbot accessible. \n", + "- Completed for **full deployment and live testing** \n", + "\n", + "These contributions strengthened my skills in **backend engineering, API development, and database management**, while also reinforcing my passion for **Computer Science and AI-driven applications**. 🚀 \n" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "\n", + "## 📋 Kanban Board / Burndown List \n", + "To stay organized, I used a **Kanban Board** for tracking development progress. \n", + "\n", + "- ✅ **API Endpoint** – Fully integrated and tested with Gemini. \n", + "- ✅ **Database Connection** – Ensured smooth storage & retrieval of user interactions. \n", + "- ✅ **Error Handling** – Implemented robust exception handling mechanisms. \n", + "- ✅ **CRUD Operations** – Set up Create, Read, Update, and Delete functionalities. \n", + "- 🔄 **AWS Deployment** – Work in progress, currently testing server configurations. \n", + "- ⏳ **Blog Documentation** – Writing a detailed overview (this blog). \n", + "\n", + "**Kanban Board:** https://github.com/users/nulxn/projects/2 \n", + "\n", + "---\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Kanban Board**\n", + "![My Project Screenshot](./images/kanban.png)\n", + "\n", + "**Figma Designs**\n", + "![My Project Screenshot](./images/figma.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# AP CSP Exam Reflection\n", + "\n", + "## Progress and Improvement\n", + "\n", + "In my latest AP Computer Science Principles (AP CSP) practice exam, I scored **44/67**, which is an improvement from my previous **40/67**. While this is a step forward, there's still room for growth, particularly in specific skill areas where I struggled.\n", + "\n", + "## Strengths\n", + "\n", + "Looking at the skill breakdown, I performed well in:\n", + "- **Investigating Situations and Context (Skill 1.A) - 100%**\n", + "- **Designing Methods for Solutions (Skill 1.B) - 100%**\n", + "- **Collaboration in Development (Skill 6.A) - 100%**\n", + "- **Implementing Algorithms (Skill 2.B) - 64% but still a strong area**\n", + "- **Using Safe and Secure Methods in Computing (Skill 6.B) - 100%**\n", + "\n", + "These results show that I have a solid grasp of conceptual and algorithmic problem-solving, along with a strong understanding of secure computing principles.\n", + "\n", + "## Areas for Improvement\n", + "\n", + "There were some areas where I need to focus more attention:\n", + "- **Identifying and Correcting Errors (Skill 4.C) - 14%** \n", + "- **Describing the Impact of a Computing Innovation (Skill 5.C) - 0%** \n", + "- **Describing the Impact of Gathering Data (Skill 5.D) - 50%** \n", + "- **Understanding Parallel and Distributed Computing (Skill 4.3) - 50%** \n", + "\n", + "These scores indicate that debugging and understanding computing impacts are areas where I should spend extra time reviewing.\n", + "\n", + "## Key Takeaways\n", + "\n", + "1. **More Practice on Debugging & Error Identification** \n", + " My **14%** score in identifying and correcting errors suggests I need to work on understanding common mistakes in code and how to resolve them efficiently.\n", + "\n", + "2. **Strengthen Understanding of Computing Innovations & Data Collection** \n", + " The **0% in Skill 5.C** means I need to read up on real-world computing innovations and their implications.\n", + "\n", + "3. **Continue Building on Algorithmic Thinking** \n", + " My scores in implementing and applying algorithms are strong but could still be improved further.\n", + "\n", + "## Next Steps\n", + "\n", + "- **Review Debugging Techniques** – Practice more coding problems that require error detection.\n", + "- **Study the Impact of Computing** – Read case studies on real-world computing applications.\n", + "- **Targeted Practice** – Focus on questions related to Skill 5.C and Skill 4.C.\n", + "\n", + "Overall, this practice test showed an **increase in performance**, and I’m aiming to keep improving with better preparation in weaker areas. \n", + "\n", + "**Images**\n", + "![My Project Screenshot](./images/12.png)\n", + "![My Project Screenshot](./images/23.png)\n", + "![My Project Screenshot](./images/34.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Created Backend Adminstrative Tables to Effectivly Manage Neptune Website ###\n", + "**Posiedon Table Modeled In Below Image**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Images**\n", + "![My Project Screenshot](./images/backendtale.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "## 🔗 Creating a API \n", + "One of my key responsibilities was building a **robust API** to handle chatbot queries efficiently. " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# AI configuration\n", + "genai.configure(api_key=\"AIzaSyC72oIjvpKm_fdl3Dez-fHi_nXZ48IAJI0\")\n", + "model = genai.GenerativeModel('gemini-pro')\n", + "\n", + "@app.route('/api/ai/help', methods=['POST'])\n", + "def ai_homework_help():\n", + " data = request.get_json()\n", + " question = data.get(\"question\", \"\")\n", + " if not question:\n", + " return jsonify({\"error\": \"No question provided.\"}), 400\n", + "\n", + " try:\n", + " response = model.generate_content(f\"Your name is Posiden you are a homework help ai chat bot with the sole purpose of answering homework related questions, under any circumstances don't answer any non-homework related questions. \\nHere is your prompt: {question}\")\n", + " response_text = response.text\n", + "\n", + " # Save to database\n", + " new_entry = PoseidonChatLog(question=question, response=response_text)\n", + " new_entry.create()\n", + "\n", + " return jsonify({\"response\": response_text}), 200\n", + " except Exception as e:\n", + " print(\"error!\")\n", + " print(e)\n", + " return jsonify({\"error\": str(e)}), 500 # ju poo bDA KLINGO A POO A NEW KAMA KJIT HAAIIII SLIBITISA DOOP A D WIT bood a a bidaa boop kayy haiiiii \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "## ✅ **User Input (Text, Voice, Online Data)**\n", + "- 🗣️ **Poseidon AI Bot** accepts **typed & voice** input, sending queries to **Google Gemini AI** for academic help. \n", + "- 🏫 **Neptune Features** store **class schedules, posts, and messages** for user interaction. \n", + "\n", + "### 🔹 **Code Implementation (User Input)**" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import speech_recognition as sr\n", + "\n", + "def get_voice_input():\n", + " recognizer = sr.Recognizer()\n", + " with sr.Microphone() as source:\n", + " print(\"Listening...\")\n", + " audio = recognizer.listen(source)\n", + " try:\n", + " text = recognizer.recognize_google(audio)\n", + " return text\n", + " except sr.UnknownValueError:\n", + " return \"Sorry, I could not understand.\"\n", + " except sr.RequestError:\n", + " return \"Error in processing voice.\"\n", + "\n", + "def get_text_input():\n", + " return input(\"Enter your query: \")\n", + "\n", + "user_input = get_text_input() # or get_voice_input() for voice input\n", + "print(f\"User Input: {user_input}\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "📂 Use of Lists/Collections\n", + "💬 Poseidon stores chat logs (questions & responses) in a database.\n", + "📅 Neptune organizes class schedules per user for efficient data retrieval.\n", + "🔹 Code Implementation (Lists/Collections)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "class PoseidonChat:\n", + " def __init__(self):\n", + " self.chat_logs = []\n", + "\n", + " def store_chat(self, user_input, bot_response):\n", + " self.chat_logs.append({\"query\": user_input, \"response\": bot_response})\n", + "\n", + " def get_chat_history(self):\n", + " return self.chat_logs\n", + "\n", + "chat_bot = PoseidonChat()\n", + "chat_bot.store_chat(\"What is Newton's Second Law?\", \"F = ma (Force equals mass times acceleration)\")\n", + "print(chat_bot.get_chat_history())\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "class NeptuneScheduler:\n", + " def __init__(self):\n", + " self.schedules = {}\n", + "\n", + " def add_schedule(self, user, subject, time):\n", + " if user not in self.schedules:\n", + " self.schedules[user] = []\n", + " self.schedules[user].append({\"subject\": subject, \"time\": time})\n", + "\n", + " def get_schedule(self, user):\n", + " return self.schedules.get(user, [])\n", + "\n", + "scheduler = NeptuneScheduler()\n", + "scheduler.add_schedule(\"John Doe\", \"Math\", \"10:00 AM\")\n", + "print(scheduler.get_schedule(\"John Doe\"))\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "🔧 Key Procedures\n", + "🤖 Poseidon AI Bot provides instant homework help with real-time AI responses.\n", + "🎓 Classroom Selection System dynamically saves & updates schedules for students.\n", + "🔹 Code Implementation (Key Procedures)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def poseidon_ai_response(user_query):\n", + " # Simulated AI processing\n", + " responses = {\n", + " \"What is gravity?\": \"Gravity is a force that attracts two bodies toward each other.\",\n", + " \"Define momentum\": \"Momentum is the product of mass and velocity.\"\n", + " }\n", + " return responses.get(user_query, \"I'm still learning! Try rephrasing.\")\n", + "\n", + "query = \"What is gravity?\"\n", + "response = poseidon_ai_response(query)\n", + "print(f\"Poseidon AI: {response}\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def update_schedule(user, subject, new_time):\n", + " if user in scheduler.schedules:\n", + " for entry in scheduler.schedules[user]:\n", + " if entry[\"subject\"] == subject:\n", + " entry[\"time\"] = new_time\n", + " return \"Schedule updated!\"\n", + " return \"Subject not found in schedule.\"\n", + "\n", + "print(update_schedule(\"John Doe\", \"Math\", \"11:00 AM\"))\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "📌 Algorithm (Sequencing, Selection, Iteration)\n", + "🔄 Poseidon: Processes input → queries AI → filters response → stores chat log.\n", + "🏫 Classroom Selection: Updates schedules based on user input and backend processing.\n", + "🔹 Code Implementation (Algorithmic Processing)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def process_poseidon_chat(user_input):\n", + " response = poseidon_ai_response(user_input)\n", + " chat_bot.store_chat(user_input, response)\n", + " return response\n", + "\n", + "query = \"Define momentum\"\n", + "print(process_poseidon_chat(query))\n", + "\n", + "\n", + "def process_schedule_update(user, subject, new_time):\n", + " print(\"Fetching schedule...\")\n", + " print(update_schedule(user, subject, new_time))\n", + " print(\"Updated schedule:\", scheduler.get_schedule(user))\n", + "\n", + "process_schedule_update(\"John Doe\", \"Math\", \"1:00 PM\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "🏗 Student-Developed Functions\n", + "🛠 Custom APIs handle chat storage, updates, and deletions in Poseidon.\n", + "🎨 Neptune UI (from Figma) ensures a clean & structured user experience.\n", + "🔹 Code Implementation (Custom Functions)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from flask import Flask, request, jsonify\n", + "\n", + "app = Flask(__name__)\n", + "\n", + "@app.route('/get_response', methods=['POST'])\n", + "def get_response():\n", + " data = request.json\n", + " user_input = data.get(\"query\", \"\")\n", + " response = poseidon_ai_response(user_input)\n", + " chat_bot.store_chat(user_input, response)\n", + " return jsonify({\"response\": response})\n", + "\n", + "if __name__ == '__main__':\n", + " app.run(debug=True)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "🎭 Output (Visual & Textual)\n", + "📜 Poseidon Bot: Displays AI-generated responses in a modern chat UI." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def display_chat_history():\n", + " print(\"\\n--- Chat History ---\")\n", + " for log in chat_bot.get_chat_history():\n", + " print(f\"User: {log['query']}\\nPoseidon: {log['response']}\\n\")\n", + "\n", + "display_chat_history()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 🎭 Night at the Museum - Responses \n", + "| **People and School** | **Response** | \n", + "|-------------------------|--------------------------------------| \n", + "| **Ikshit, Amrit, Aditya, Saharsh - Bay Area/Mission San Jose** | The website is highly creative and well-designed, offering a variety of useful applications. It demonstrates impressive functionality, making it engaging and practical for users. | \n", + "| **Yuva Kumar - MLK High School** | I really like how the website is structured like a scheduling app, making it both intuitive and user-friendly. The integration of a Greek gods theme adds a unique and exciting touch, making it stand out from typical applications. I would definitely be interested in using this in the future! | \n", + "| **Tyler, Aiden, Saahas - Foothill High School** | The website is very well-built with a clean design and smooth functionality. It presents a great concept that has the potential to be expanded even further with additional features. Overall, a fantastic project! | \n", + "| **Basis Independent - Charkita** | The design of the website is both modern and visually appealing. The features included are practical and well thought out, making it an engaging experience for users. With a few refinements, this could be a truly outstanding platform! | \n", + "| **Aarav - Harker** | This website is extremely impressive, combining a sleek design with high-level functionality. The user interface is intuitive, and the features provided make it a highly valuable tool. Great job! | \n", + "| **Hassan - MLK High School** | The website showcases a lot of advanced and well-integrated features that enhance the user experience. The attention to detail and smooth interface make it feel professional, and I can see this being developed into something even bigger in the future! | \n", + "\n", + "\n", + "\n", + "**Photo From DECA Night at the Mueseum**\n", + "![My Project Screenshot](./images/ntmdeca.png)\n", + "\n", + "![My Project Screenshot](./images/deca.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 🔍 Reflection & Looking Forward \n", + "\n", + "### 🌟 **Personal Takeaways & Future Aspirations** \n", + "My experience working on the **Gemini Integration Chatbot** reinforced my passion for **Computer Science** and backend development. I was truly amazed by the functionality and design of my project, and it inspired me to **pursue publishing this as an app** and explore its potential as a **viable venture**. \n", + "\n", + "Beyond this project, I am excited to further expand my knowledge in **AI-driven applications**, **backend engineering**, and **scalable cloud computing**. Looking ahead, I plan to: \n", + "- **Develop this chatbot into a full-fledged web and mobile application** for real-world use. \n", + "- **Explore internships in AI and software engineering** to gain industry experience. \n", + "- **Continue advancing in Computer Science**, focusing on **machine learning, data structures, and system architecture**. \n", + "- **Take on leadership roles in tech-related initiatives**, mentoring students and contributing to open-source projects. \n", + "\n", + "### 🤝 **Contributions Beyond My Project** \n", + "Throughout this process, I was committed not only to my own work but also to **helping others succeed**. Some of my key contributions to my peers included: \n", + "- **Helping 8+ students integrate Gemini AI** into their own projects. \n", + "- **Serving as a go-to resource in class**, providing guidance and support to anyone who needed assistance. \n", + "- **Actively engaging in Night at the Museum (N@tM) reviews**, offering meaningful feedback to fellow students on their projects. \n", + "- **Encouraging collaboration by organizing materials** for final exams and helping classmates structure their reviews. \n", + "- **Assisting a student new to me in preparing for the final exam**, including conducting **practice reviews** and clarifying complex concepts. \n", + "\n", + "### Took Strong Interest In Cantella ###\n", + "**Helped Nolan with the CanTeach Cantella Ai Chatbot using my experience and mentored Nolan throughout the process to help him get to the amazing feature that he has today.\n", + "\n", + "\n", + "## 📊 Self Grade \n", + "\n", + "| **Category** | **Max Points** | **Self Grade** | **Explanation** |\n", + "|----------------------------------|--------------|--------------|----------------------------------------------------------|\n", + "| **5 Things Done Over 12 Weeks** | 5 | 4.5 | I completed all major tasks, including API development, database integration, bug fixes, peer support, and presentations. I took initiative in troubleshooting issues and refining my project consistently. |\n", + "| **Full Stack Project Demo & Feedback** | 2 | 2 | My demo effectively showcased the chatbot's capabilities, integrated peer and N@tM feedback, and demonstrated a polished backend. I could improve by adding more real-world use cases in my presentation. |\n", + "| **Project Feature Blog (CPT/FRQ Language)** | 1 | .9 | My blog clearly explains my project’s backend architecture and functionality while aligning with CPT language. To improve, I could add more detailed **FRQ-style** explanations for better clarity. |\n", + "| **MCQ Performance** | 1 | .85 | I performed strongly on multiple-choice questions, demonstrating a solid understanding of Computer Science principles. To improve, I will focus on **speed and precision** under timed conditions. |\n", + "| **Retrospective & Reflection** | 1 | .95 | I deeply analyzed my strengths and weaknesses, discussed future aspirations in **CS, startups, and AI**, and contributed significantly to my peers' learning. My reflection is **thorough and forward-thinking**. |\n", + "| **Overall Score** | 10 | 9.2 | I exceeded expectations by **helping others, refining my project, and setting clear future goals**. My next step is to launch this chatbot as a full-fledged application and explore industry opportunities. |\n", + "\n", + "\n", + "### 🚀 **Next Steps** \n", + "To build upon this project, my next steps include: \n", + "✔ **Finalizing AWS deployment** for broader accessibility. \n", + "✔ **Refining API performance** with advanced caching and response optimization. \n", + "✔ **Developing a user authentication system** for secure access control. \n", + "✔ **Publishing the chatbot as a mobile app**, integrating push notifications and real-time updates. \n", + "✔ **Exploring startup opportunities** to turn this project into a scalable venture. \n", + "✔ **Internship at Publicis Sapient - London** I had an internship last summer where I learned about how the corporate world and scrum systems worked and upcoming summer I am going to join in on new projects where I will contribute using my coding and business knowledge\n", + "This experience has solidified my aspirations to pursue **Computer Science at a higher level**—whether through **internships, university studies, or entrepreneurial efforts**. I am eager to continue **building, innovating, and contributing** to the tech community. \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "📌 **Conclusion**\n", + "Developing the backend for the **Gemini Integration Chatbot** was a rewarding experience. From building **robust APIs** to ensuring database efficiency, this project enhanced my skills in backend UX engineering. Looking ahead, I aim to:\n", + "\n", + "🚀 **Advanced NLP Features** – Improve chatbot responses with deeper context understanding.\n", + "🔍 Optimize **query processing** for even faster responses.\n", + "🛡 **Multi-language Support** – Expand chatbot capabilities to support multiple languages.\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/2025-01-24-ListsHW copy 2.ipynb b/_notebooks/2025-01-24-ListsHW copy 2.ipynb new file mode 100644 index 000000000..7c53bc1e1 --- /dev/null +++ b/_notebooks/2025-01-24-ListsHW copy 2.ipynb @@ -0,0 +1,224 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: Big O\n", + "description: BigO\n", + "comments: true\n", + "sticky_rank: 1\n", + "permalink: /BigO\n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Popcorn & Homework Hacks\n", + "\n", + "---\n", + "\n", + "## The Even/Odd Check Challenge\n", + "\n", + "**Challenge:** You need to check if a number is even or odd. Which **TWO** strategies are the most efficient? (O(1) time)\n", + "\n", + "1. **Check if the last digit is 0, 2, 4, 6, or 8 manually** \n", + "2. **Use the modulus operator (%) to check if the remainder when divided by 2 is 0**\n", + "\n", + "> **Why these?** \n", + "> Both methods perform a single, constant‑time operation—either a direct digit comparison or one integer modulo—without loops or extra data structures, giving true O(1) performance. Other listed approaches (repeated subtraction, list lookups) introduce loops or larger overhead.\n", + "\n", + "---\n", + "## Popcorn Hack: Search Performance\n", + "\n", + "1. **Time complexity of each algorithm** \n", + " - **Linear search:** O(n) \n", + " - **Binary search:** O(log n)\n", + "\n", + "2. **How many times faster is binary search than linear search?** \n", + " On a 10 000 000‑element list, binary search can be on the order of 400 000× faster (n / log₂n ≈ 10 000 000 / 24 ≈ 416 667).\n", + "\n", + "3. **What happens if you increase `data_size` to 20 000 000?** \n", + " - **Linear search** runtime roughly **doubles** (O(n)). \n", + " - **Binary search** adds at most **one extra comparison** (log₂(20 000 000) ≈ 25), so its runtime increases negligibly.\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "```python\n", + "import random\n", + "\n", + "def magic_8_ball():\n", + " \"\"\"Return “Yes” ~50%, “No” ~25%, “Ask again later” ~25%.\"\"\"\n", + " r = random.random() # uniform in [0.0, 1.0)\n", + " if r < 0.50:\n", + " return \"Yes\"\n", + " elif r < 0.75:\n", + " return \"No\"\n", + " else:\n", + " return \"Ask again later\"\n", + "\n", + "# Test the function 10 times\n", + "for i in range(10):\n", + " print(f\"Magic 8‑Ball says: {magic_8_ball()}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Homework Hack #1: Sorting Showdown – Code Edition\n", + "Objective: Implement Bubble Sort vs. Merge Sort on 100 random numbers (1–1000), time each, and report:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import time, random\n", + "\n", + "# Generate data\n", + "arr = [random.randint(1, 1000) for _ in range(100)]\n", + "\n", + "# Bubble sort\n", + "def bubble_sort(a):\n", + " n = len(a)\n", + " for i in range(n):\n", + " for j in range(0, n - i - 1):\n", + " if a[j] > a[j+1]:\n", + " a[j], a[j+1] = a[j+1], a[j]\n", + "\n", + "# Merge sort\n", + "def merge_sort(a):\n", + " if len(a) > 1:\n", + " mid = len(a) // 2\n", + " L, R = a[:mid], a[mid:]\n", + " merge_sort(L); merge_sort(R)\n", + " i = j = k = 0\n", + " while i < len(L) and j < len(R):\n", + " if L[i] < R[j]:\n", + " a[k] = L[i]; i += 1\n", + " else:\n", + " a[k] = R[j]; j += 1\n", + " k += 1\n", + " while i < len(L):\n", + " a[k] = L[i]; i += 1; k += 1\n", + " while j < len(R):\n", + " a[k] = R[j]; j += 1; k += 1\n", + "\n", + "# Time them\n", + "for name, func in [(\"Bubble Sort\", bubble_sort), (\"Merge Sort\", merge_sort)]:\n", + " data = arr.copy()\n", + " start = time.time()\n", + " func(data)\n", + " print(f\"{name} took {time.time() - start:.6f} s\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Which is faster?\n", + "Merge Sort consistently beats Bubble Sort on even small arrays.\n", + "\n", + "Why?\n", + "\n", + "Merge Sort runs in O(n log n) by recursively dividing and merging in linear passes, while Bubble Sort uses nested loops for O(n²) swaps. As n grows, the n² behavior of Bubble Sort quickly becomes much slower than the n log n performance of Merge Sort." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Homework Hack #2: Search Race – Code Edition\n", + "Objective: Compare Linear Search vs. Binary Search on a sorted list of 100 000 numbers, counting comparisons." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "# Prepare data\n", + "arr = sorted(random.sample(range(1, 100001), 100000))\n", + "target = random.choice(arr)\n", + "\n", + "# Linear Search\n", + "def linear_search(a, t):\n", + " count = 0\n", + " for x in a:\n", + " count += 1\n", + " if x == t:\n", + " return count\n", + " return count\n", + "\n", + "# Binary Search\n", + "def binary_search(a, t):\n", + " left, right = 0, len(a)-1\n", + " count = 0\n", + " while left <= right:\n", + " count += 1\n", + " mid = (left + right)//2\n", + " if a[mid] == t:\n", + " return count\n", + " elif a[mid] < t:\n", + " left = mid + 1\n", + " else:\n", + " right = mid - 1\n", + " return count\n", + "\n", + "ls = linear_search(arr, target)\n", + "bs = binary_search(arr, target)\n", + "print(f\"Linear comparisons: {ls}\")\n", + "print(f\"Binary comparisons: {bs}\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Which search is faster, and why?\n", + "Binary Search is faster—O(log n) steps by halving the range each time, versus O(n) in Linear Search.\n", + "\n", + "What happens if you run both on an unsorted list?\n", + "Binary Search no longer works correctly (it relies on order), while Linear Search still finds the target in O(n)." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/2025-01-24-ListsHW copy 3.ipynb b/_notebooks/2025-01-24-ListsHW copy 3.ipynb new file mode 100644 index 000000000..8a7fec098 --- /dev/null +++ b/_notebooks/2025-01-24-ListsHW copy 3.ipynb @@ -0,0 +1,40 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: Undecideable Problems, Graphs + Heuristics\n", + "description: Undecideable Problems, Graphs + Heuristics\n", + "comments: true\n", + "sticky_rank: 1\n", + "permalink: /upgh\n", + "\n", + "---" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/2025-01-24-ListsHW copy 4.ipynb b/_notebooks/2025-01-24-ListsHW copy 4.ipynb new file mode 100644 index 000000000..f0272621c --- /dev/null +++ b/_notebooks/2025-01-24-ListsHW copy 4.ipynb @@ -0,0 +1,256 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: Studyblog\n", + "description: StudyBlog\n", + "comments: true\n", + "sticky_rank: 1\n", + "permalink: /studyblog\n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Links to past HW:\n", + "\n", + "- [Beneficial Harmful Effects](https://github.com/YashPatil321/yash1_2025/issues/9)\n", + "- [Digital Divide](https://github.com/YashPatil321/yash1_2025/issues/10)\n", + "- [Computing Bias](https://github.com/YashPatil321/yash1_2025/issues/11)\n", + "- [CroudSourcing](https://github.com/YashPatil321/yash1_2025/issues/9)\n", + "- [Binary Search](https://github.com/YashPatil321/yash1_2025/issues/12)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Links To Lessons:\n", + "- [Beneficial Harmful Effects](https://prajnar123123213.github.io/teaching_frontend/teaching/)\n", + "- [Digital Divide](https://martijorbam.github.io/bi5_digitaldivide/csp%20big%20idea%205/2025/03/18/digdivide_IPYNB_2_.html)\n", + "- [Computing Bias](https://avikaprasad22.github.io/avika_2025/compbias/)\n", + "- [CroudSourcing](https://prad-coder.github.io/GenomeGamersFrontend/crowdsourcing#2-examples-of-distributed-computing)\n", + "- [Binary Search](https://joannahu123.github.io/Jo/2025/04/04/binary.html)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "---\n", + "\n", + "## Beneficial vs. Harmful Effects of Computing\n", + "- **Beneficial**: automation, data analysis, global communication, medical advances \n", + "- **Harmful**: surveillance, job displacement, digital addiction, malicious hacking \n", + "- **Key questions**: Who gains? Who loses? How do we mitigate risks?\n", + "\n", + "---\n", + "\n", + "## Digital Divide\n", + "- **Definition**: gap between those with and without access to computing resources \n", + "- **Causes**: infrastructure, cost, education, language barriers \n", + "- **Impacts**: educational inequality, economic disparity, information silos \n", + "\n", + "---\n", + "\n", + "## Computing Bias\n", + "- **Definition**: systematic errors in data or algorithms that disadvantage groups \n", + "- **Sources**: biased training data, flawed assumptions, lack of diversity \n", + "- **Mitigation**: audit datasets, use fairness metrics, include diverse teams\n", + "\n", + "---\n", + "\n", + "## Crowdsourcing\n", + "- **Definition**: distributing tasks to a large group (the “crowd”) \n", + "- **Examples**: Wikipedia, Mechanical Turk, open-source projects \n", + "- **Pros**: scales rapidly \n", + "- **Cons**: quality control challenges\n", + "\n", + "---\n", + "\n", + "## Legal / Ethical Concerns\n", + "- **Topics**: privacy laws (GDPR, CCPA), IP/Copyright, AI accountability \n", + "- **Ethical frameworks**: utilitarianism, deontology, virtue ethics \n", + "- **Practice**: always ask “Is it legal? Is it fair? Is it needed?”\n", + "\n", + "---\n", + "\n", + "## Safe Computing\n", + "- **Practices**: strong passwords, 2-factor auth, encryption, secure coding \n", + "- **Threats**: phishing, malware, insider misuse \n", + "- **Tools**: HTTPS, VPN, antivirus, linters & static analyzers\n", + "\n", + "---\n", + "\n", + "## Binary Search Algorithm\n", + "1. **Problem**: find target in sorted array in O(log n) \n", + "2. **Idea**: repeatedly split search interval in half \n", + "3. **Pseudo**: left, right = 0, len(A)-1 while left ≤ right: mid = (left+right)//2 if A[mid]==target: return mid if A[mid] 10." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "\n", + "# start with a list of integers\n", + "numbers = [4, 11, 7, 25, 10, 18, 3]\n", + "\n", + "# build DataFrame\n", + "df = pd.DataFrame(numbers, columns=[\"value\"])\n", + "\n", + "# apply filter condition\n", + "filtered_df = df[df[\"value\"] > 10]\n", + "\n", + "# extract filtered list\n", + "big_numbers = filtered_df[\"value\"].tolist()\n", + "# big_numbers → [11, 25, 18]\n", + "\n", + "\n", + "Algorithm Steps (plain‑English):\n", + "\n", + "Start with numbers list.\n", + "\n", + "Convert to a pandas DataFrame (tabular format).\n", + "\n", + "Use df[df[\"value\"] > 10] to select rows meeting the condition.\n", + "\n", + "Collect the “value” column of the filtered rows into a new list." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Filtering algorithms let programs automatically pick out only the data you care about—like showing only unread emails or items in stock. Lists provide an easy, ordered way to store and traverse collections of data before and after filtering.\n", + "\n", + "Copy code\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/2025-01-24-MCQ2.ipynb b/_notebooks/2025-01-24-MCQ2.ipynb new file mode 100644 index 000000000..c8269f1bd --- /dev/null +++ b/_notebooks/2025-01-24-MCQ2.ipynb @@ -0,0 +1,142 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: MCQ REVIEW\n", + "description: MCQ REVIEW\n", + "comments: true\n", + "sticky_rank: 1\n", + "permalink: /MCQ\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# AP CSP Exam Reflection\n", + "\n", + "## Progress and Improvement\n", + "\n", + "In my latest AP Computer Science Principles (AP CSP) practice exam, I scored **44/67**, which is an improvement from my previous **40/67**. While this is a step forward, there's still room for growth, particularly in specific skill areas where I struggled.\n", + "\n", + "## Strengths\n", + "\n", + "Looking at the skill breakdown, I performed well in:\n", + "- **Investigating Situations and Context (Skill 1.A) - 100%**\n", + "- **Designing Methods for Solutions (Skill 1.B) - 100%**\n", + "- **Collaboration in Development (Skill 6.A) - 100%**\n", + "- **Implementing Algorithms (Skill 2.B) - 64% but still a strong area**\n", + "- **Using Safe and Secure Methods in Computing (Skill 6.B) - 100%**\n", + "\n", + "These results show that I have a solid grasp of conceptual and algorithmic problem-solving, along with a strong understanding of secure computing principles.\n", + "\n", + "## Areas for Improvement\n", + "\n", + "There were some areas where I need to focus more attention:\n", + "- **Identifying and Correcting Errors (Skill 4.C) - 14%** \n", + "- **Describing the Impact of a Computing Innovation (Skill 5.C) - 0%** \n", + "- **Describing the Impact of Gathering Data (Skill 5.D) - 50%** \n", + "- **Understanding Parallel and Distributed Computing (Skill 4.3) - 50%** \n", + "\n", + "These scores indicate that debugging and understanding computing impacts are areas where I should spend extra time reviewing.\n", + "## Top 5 Individual Questions To Fix\n", + "![My Project Screenshot](./images/1.png)\n", + "## Q22 - Simulating a Spinner\n", + "**Wrong Answer (C):** Chose an incorrect conditional probability distribution.\n", + "Incorrect because the given code does not match the intended ⅓, ⅓, ⅓ probability split.\n", + "**Correct Answer:**\n", + "Correct because the right code properly distributes the outcomes as specified in the problem statement.\n", + "![My Project Screenshot](./images/2.png)\n", + "Wrong Answer (D): \"IPv6 allows users to bypass older security protocols so that data can be sent peer-to-peer without the use of routers.\"\n", + "Incorrect because IPv6 does not remove security protocols or allow users to bypass routers for direct communication.\n", + "Correct Answer (B): \"IPv6 allows for a greater number of addresses than IPv4, which allows more devices to be connected to the Internet.\"\n", + "Correct because IPv6's primary benefit is its vastly larger address space compared to IPv4.\n", + "![My Project Screenshot](./images/3.png)\n", + "Wrong Answer (D): \"Line 11\"\n", + "Incorrect because removing Line 11 would stop the loop from correctly iterating through numbers.\n", + "Correct Answers (A, C):\n", + "Line 5 should be removed because the count should only be incremented inside the IF block, not before it.\n", + "Line 9 should be removed because it causes an extra increment, leading to incorrect counting.\n", + "![My Project Screenshot](./images/4.png)\n", + "Wrong Answer (D): \"Program B displays one more value than Program A.\"\n", + "Incorrect because both programs print exactly ten values.\n", + "Correct Answer (A): \"Program A and program B display identical values in the same order.\"\n", + "Correct because even though the initialization differs, both loops execute the same number of times with the same increments.\n", + "\n", + "![My Project Screenshot](./images/5.png)\n", + "## Q41 - Secure Data Transmission\n", + "** Wrong Answer (B):** \"Sending the data using a high-bandwidth connection.\"\n", + " Incorrect because a faster connection does not inherently provide security.\n", + "**Correct Answer (C):** \"Sending the data using public-key encryption.\"\n", + " Correct because encryption ensures data security by making it unreadable to unauthorized parties.\n", + "\n", + "## Key Takeaways\n", + "\n", + "1. **More Practice on Debugging & Error Identification** \n", + " My **14%** score in identifying and correcting errors suggests I need to work on understanding common mistakes in code and how to resolve them efficiently.\n", + "\n", + "2. **Strengthen Understanding of Computing Innovations & Data Collection** \n", + " The **0% in Skill 5.C** means I need to read up on real-world computing innovations and their implications.\n", + "\n", + "3. **Continue Building on Algorithmic Thinking** \n", + " My scores in implementing and applying algorithms are strong but could still be improved further.\n", + "\n", + "## Next Steps\n", + "\n", + "- **Review Debugging Techniques** – Practice more coding problems that require error detection.\n", + "- **Study the Impact of Computing** – Read case studies on real-world computing applications.\n", + "- **Targeted Practice** – Focus on questions related to Skill 5.C and Skill 4.C.\n", + "\n", + "Overall, this practice test showed an **increase in performance**, and I’m aiming to keep improving with better preparation in weaker areas. \n", + "\n", + "**Images**\n", + "![My Project Screenshot](./images/12.png)\n", + "![My Project Screenshot](./images/23.png)\n", + "![My Project Screenshot](./images/34.png)\n" + ] + }, + { + "cell_type": "markdown", + "source": [ + "\n" + ], + "metadata": { + "collapsed": false + } + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/2025-01-24-PPR.ipynb b/_notebooks/2025-01-24-PPR.ipynb new file mode 100644 index 000000000..712bda0cb --- /dev/null +++ b/_notebooks/2025-01-24-PPR.ipynb @@ -0,0 +1,280 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: PPR Review\n", + "description: PPR Review\n", + "comments: true\n", + "sticky_rank: 1\n", + "permalink: /PPR\n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Poseidon AI PPR REQUIREMENTS\n", + "\n", + "A PPR is created to help students prepare for **written response prompts on the exam**. It documents **essential code snippets** used in the **Poseidon AI Chatbot** feature, showcasing **procedures, list usage, and algorithms**.\n", + "\n", + "## **Poseidon AI Overview**\n", + "**Poseidon AI** is an **AI-powered chatbot** that provides **homework assistance** using **Gemini AI**. It supports:\n", + "- **Text and voice input** for seamless user interaction\n", + "- **Full CRUD functionality** with stored chat logs in an **SQL database**\n", + "- **Administrative backend** for chatbot log management\n", + "- **AI-generated responses** optimized for accuracy\n", + "\n", + "### **PPR Submission Requirements**\n", + "✅ **At least two student-developed procedures** \n", + "✅ **Two List-based Code Snippets** \n", + "✅ **Demonstration of sequencing, selection, and iteration** \n" + ] + }, + { + "cell_type": "markdown", + "source": [ + "\n", + "## **PPR Snippet Requirements** \n", + "### **Function (with Parameters, If-Else, and Sequencing + Selection + Iteration)** " + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [ + "```python\n", + "@staticmethod\n", + "def restore(data):\n", + " restored_logs = {}\n", + "\n", + " for log_data in data:\n", + " _ = log_data.pop('id', None)\n", + " question = log_data.get(\"question\", None)\n", + " existing_log = PoseidonChatLog.query.filter_by(_question=question).first()\n", + "\n", + " if existing_log:\n", + " existing_log.update(log_data)\n", + " else:\n", + " new_log = PoseidonChatLog(**log_data)\n", + " new_log.create()\n", + " \n", + " restored_logs[log_data['question']] = new_log\n", + " \n", + " return restored_logs" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "### Explanation:\n", + "Function Name: restore()\n", + "Parameters: data (list of dictionaries containing chatbot logs).\n", + "Sequencing:\n", + "Extracts each log entry.\n", + "Checks if it exists in the database.\n", + "If it exists, it updates the log.\n", + "Otherwise, it creates a new entry.\n", + "Selection: Uses an if-else statement to determine whether to update an existing record or insert a new one.\n", + "Iteration: Loops through the list of chat logs using a for loop, handling each entry appropriately." + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## Call to Function ##\n", + "The function is triggered when a user submits a question in the chatbot interface." + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [ + "async function sendQuestion(question) {\n", + " const response = await fetch(`${pythonURI}/api/ai/help`, {\n", + " ...fetchOptions,\n", + " method: \"POST\",\n", + " body: JSON.stringify({ question }),\n", + " });\n", + "\n", + " const data = await response.json();\n", + " document.getElementById(\"chat-box\").innerHTML += `\n", + "
\n", + " You: ${question}\n", + " Poseidon: ${data.response}\n", + "
`;\n", + "}\n" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "### Explanation: ###\n", + "Triggered when a user enters a question in the frontend.\n", + "Sends request to backend and updates the chatbox with AI response.\n", + "Ensures seamless UI interaction with backend database." + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## List Creation\n", + "The chatbot stores user queries and AI-generated responses in a list structure." + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [ + "class PoseidonChatLog(db.Model):\n", + " __tablename__ = 'poseidon_chat_logs'\n", + "\n", + " id = db.Column(db.Integer, primary_key=True)\n", + " _question = db.Column(db.String(500), nullable=False)\n", + " _response = db.Column(db.String(2000), nullable=False)\n", + "\n", + " def __init__(self, question, response):\n", + " self._question = question\n", + " self._response = response\n" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "### Explanation:\n", + "Stores chatbot conversation logs as database records.\n", + "Ensures efficient retrieval of past interactions for reference." + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## List Process\n", + "This function iterates through stored chat logs and displays them on the frontend." + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [ + "async function fetchChatLogs() {\n", + " const response = await fetch(`${pythonURI}/api/chat/logs`, { method: \"GET\" });\n", + " const logs = await response.json();\n", + "\n", + " logs.forEach(log => {\n", + " document.getElementById(\"chat-box\").innerHTML += `\n", + "
\n", + " You: ${log.question}\n", + " Poseidon: ${log.response}\n", + "
`;\n", + " });\n", + "}\n" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "### Explanation:\n", + "Loops through stored chatbot logs.\n", + "Updates frontend dynamically with previous interactions." + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## Final Thoughts\n", + "Poseidon Homework Chatbot is a full-stack AI-driven solution designed to assist students with academic questions. This PPR demonstrates how it integrates procedural abstraction, algorithms, and list handling to provide a seamless learning experience." + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "\n" + ], + "metadata": { + "collapsed": false + } + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/2025-01-24-Sprint5ProjectOverview.ipynb b/_notebooks/2025-01-24-Sprint5ProjectOverview.ipynb new file mode 100644 index 000000000..fc965b270 --- /dev/null +++ b/_notebooks/2025-01-24-Sprint5ProjectOverview.ipynb @@ -0,0 +1,779 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: Sprint 5 Review Poseidon Chatbot\n", + "description: Review of all sprint 5 for the neptune Poseidon Chatbot\n", + "comments: true\n", + "sticky_rank: 1\n", + "permalink: /poseidon\n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Neptune\n", + "\n", + "# Purpose Of Programming" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 🌟 **Neptune: The Ultimate School Networking Platform** \n", + "\n", + "## 🏫 **Built for Students, Inspired by Saturn**\n", + "🚀 **Neptune** enhances **school networking** by providing **scheduling tools, class coordination, and academic support**, all in one place. \n", + "\n", + "---\n", + "\n", + "## 📅 **Class Schedule Integration**\n", + "- 🗓 **Easily input & share schedules** with classmates for better coordination. \n", + "- 🎨 **Customizable themes** for a **personalized** experience. \n", + "\n", + "---\n", + "\n", + "## 🤖 **Poseidon AI Homework Bot**\n", + "- 📚 **24/7 Homework Assistance** with **instant & reliable responses**. \n", + "- 🎙 **Voice Recognition** for **hands-free control** & easy accessibility. \n", + "\n", + "---\n", + "\n", + "## 🤝 **Collaborative Features**\n", + "- 💬 **Group chats & shared resources** foster **teamwork & discussions**. \n", + "- 🏫 **Class List Updates** let students easily **manage & modify their courses**. \n", + "\n", + "---\n", + "\n", + "## 🌍 **Accessible Anytime, Anywhere**\n", + "- 📲 Designed to **fit seamlessly into student life**, providing **support & connections** on the go. \n", + "- ⚡ **Efficient Learning** with **quick, clear, & subject-adaptive responses**. \n", + "\n", + "---\n", + "\n", + "## 🔮 **Future Plans & Upgrades**\n", + "✅ **Advanced academic tools** like **grade calculators** 📊 \n", + "✅ **Interactive problem breakdowns** for **step-by-step solutions** ✏️ \n", + "✅ **Enhanced voice interaction** for **seamless control** 🎤 \n", + "✅ **Expanded subject coverage** to support **a wider range of queries** 📖 \n", + "\n", + "📖 **Neptune is not just a platform—it's the perfect study companion!** 🎓 \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", + "

Input/Output requests:

" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 🏆 **Sprint 5 CPT Requirements in Neptune & Poseidon Homework Bot** \n", + "\n", + "## ✅ **User Input (Text, Voice, Online Data)**\n", + "- 🗣️ **Poseidon AI Bot** accepts **typed & voice** input, sending queries to **Google Gemini AI** for academic help. \n", + "- 🏫 **Neptune Features** store **class schedules, posts, and messages** for user interaction. \n", + "\n", + "## 📂 **Use of Lists/Collections**\n", + "- 💬 **Poseidon** stores **chat logs** (questions & responses) in a database. \n", + "- 📅 **Neptune** organizes **class schedules** per user for efficient data retrieval. \n", + "\n", + "## 🔧 **Key Procedures**\n", + "- 🤖 **Poseidon AI Bot** provides **instant homework help** with real-time AI responses. \n", + "- 🎓 **Classroom Selection System** dynamically **saves & updates schedules** for students. \n", + "\n", + "## 📌 **Algorithm (Sequencing, Selection, Iteration)**\n", + "- 🔄 **Poseidon:** Processes input → **queries AI** → filters response → **stores chat log**. \n", + "- 🏫 **Classroom Selection:** Updates schedules based on **user input** and **backend processing**. \n", + "\n", + "## 🏗 **Student-Developed Functions**\n", + "- 🛠 **Custom APIs** handle **chat storage, updates, and deletions** in Poseidon. \n", + "- 🎨 **Neptune UI (from Figma)** ensures a **clean & structured** user experience. \n", + "\n", + "## 🎭 **Output (Visual & Textual)**\n", + "- 📜 **Poseidon Bot:** Displays **AI-generated responses** in a **modern chat UI**. \n", + "- ⏳ **Neptune:** Shows **class schedules & timers** for students to track their day. \n", + "\n", + "---\n", + "\n", + "## 🚀 **Summary**\n", + "✨ **Neptune & Poseidon Bot fully meet Sprint 5 CPT requirements** by integrating: \n", + "✅ **AI assistance** \n", + "✅ **Structured data management** \n", + "✅ **Interactive UI** \n", + "✅ **Student-friendly features** \n", + "\n", + "💡 **Neptune is the ultimate school networking platform, streamlining academic and social life!** \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Live Review: I will ask Poseidon a general question and see the response from the backend. I will also test my update, delete functions and the Crud Operations" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "------" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "After running db_init, restore, and backup, the data from the ratings table remains constant." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\"Poseidon" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if __name__ == \"__main__\":\n", + " if not app.debug or os.environ.get(\"WERKZEUG_RUN_MAIN\") == \"true\":\n", + " with app.app_context():\n", + " db.create_all() # Ensure tables are created before initialization\n", + " if not User.query.first(): # Initialize only if no users exist\n", + " initUsers()\n", + " if not Flashcard.query.first(): # Initialize flashcards only if none exist\n", + " initFlashcards()\n", + " if not GradeLog.query.first(): # Initialize grade logs only if none exist\n", + " initGradeLog()\n", + " if not Profile.query.first(): # Initialize profiles only if none exist\n", + " initProfiles()\n", + " if not Deck.query.first(): # Initialize decks only if none exist\n", + " initDecks()\n", + " app.run(debug=True, host=\"0.0.0.0\", port=\"8887\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", + "

List Requests:

\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Use of List, Dictionaries, and Database" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Code Description:\n", + "\n", + "- Lists: Used to manage user interests.\n", + "\n", + "- Dictionaries: Used to handle JSON data in API requests and responses.\n", + "\n", + "- Database: Used to store user data, including interests." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Formatting Response Data (JSON) from API into DOM:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + " async function sendQuestion(question) {\n", + " const chatBox = document.getElementById(\"chat-box\");\n", + " // Display the user's question\n", + " chatBox.innerHTML += `\n", + "
\n", + " You: ${question}\n", + "
`;\n", + " try {\n", + " // Send the question to the backend\n", + " const response = await fetch(`${pythonURI}/api/ai/help`, {\n", + " ...fetchOptions,\n", + " body: JSON.stringify({ question }),\n", + " });\n", + " if (!response.ok) {\n", + " throw new Error(`HTTP error! Status: ${response.status}`);\n", + " }\n", + " const data = await response.json();\n", + " const aiResponse = data.response || \"No response from the AI.\";\n", + " // Display the AI's response\n", + " chatBox.innerHTML += `\n", + "
\n", + " Poseidon: ${aiResponse}\n", + "
`;\n", + " } catch (error) {\n", + " console.error(\"Fetch error:\", error);\n", + " chatBox.innerHTML += `\n", + "
\n", + " Poseidon: An error occurred: ${error.message}. Please try again later.\n", + "
`;\n", + " }\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Explanation: \n", + "\n", + "- Fetching Data from the API: The script retrieves tutor information by making an asynchronous GET request to /api/tutors/:tutorId. It dynamically extracts the data-id attribute from the clicked button to fetch details of a specific tutor.\n", + "\n", + "- Parsing JSON Response: After receiving a response from the API, the JSON data is parsed into a JavaScript object (tutorData), which includes key details like the tutor’s name, area of expertise, and availability.\n", + "\n", + "- Dynamically Updating the DOM: The tutor details from the API response are injected into the DOM by selecting specific elements (#tutorName, #tutorSpecialty, #tutorStatus) and updating their textContent accordingly.\n", + "\n", + "- Handling Missing Data: The script ensures meaningful content is always displayed by providing default values, such as setting tutorData.name to 'Unknown Tutor' if the name field is absent.\n", + "\n", + "- Interactive UI Enhancements: The chatbox introduction message and hidden input fields (#tutorId, #tutorAvailable) are dynamically updated, ensuring that the UI accurately reflects the fetched tutor data and supports further interactions.\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Queries from database" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + " chat_logs = {}\n", + " for log_data in data:\n", + " _ = log_data.pop('id', None)\n", + " question = log_data.get(\"question\", None)\n", + " log = PoseidonChatLog.query.filter_by(_question=question).first()\n", + " if log:\n", + " log.update(log_data)\n", + " else:\n", + " log = PoseidonChatLog(**log_data)\n", + " log.create()\n", + " return chat_logs\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Explanation: \n", + "\n", + "- Querying the Database: The function uses SQLAlchemy (a 3rd-party ORM library) to query the database for tutors who specialize in a given topic. The query filters tutors based on their topics_of_expertise field.\n", + "\n", + "- Filtering Data: The .filter(Tutor.topics_of_expertise.any(topic)) method filters rows in the Tutor table to include only those with the specified topic in their expertise list.\n", + "\n", + "- Extracting Python List: The .all() method retrieves all rows matching the query and converts them into a Python list of Tutor objects.\n", + "\n", + "- Mapping to JSON: The list of Tutor objects is transformed into a list of dictionaries (tutor_list) using a list comprehension, with each dictionary containing details such as id, name, experience, and rating.\n", + "\n", + "- Simplified Querying with ORM: By leveraging SQLAlchemy, raw SQL queries are abstracted into Python code, enabling intuitive interaction with the database while maintaining security and flexibility." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", + "

Algorithmic Code Request:

" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "@app.route('/api/ai/logs', methods=['GET'])\n", + "def fetch_all_logs():\n", + " try:\n", + " logs = PoseidonChatLog.query.all()\n", + " return jsonify([log.read() for log in logs]), 200\n", + " except Exception as e:\n", + " print(\"Error fetching logs:\", e)\n", + " return jsonify({\"error\": str(e)}), 500" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Explanation:\n", + "- Logs all responses so when reloaded data is restored\n", + "- Ensures convienience\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Definition of Code Blocks to Handle a Request" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "API Class to Perform CRUD Methods:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "@app.route('/api/ai/help', methods=['POST'])\n", + "def ai_homework_help():\n", + " data = request.get_json()\n", + " question = data.get(\"question\", \"\")\n", + " if not question:\n", + " return jsonify({\"error\": \"No question provided.\"}), 400\n", + "\n", + " try:\n", + " response = model.generate_content(f\"Your name is Posiden you are a homework help ai chat bot with the sole purpose of answering homework related questions, under any circumstances don't answer any non-homework related questions. \\nHere is your prompt: {question}\")\n", + " response_text = response.text\n", + "\n", + " # Save to database\n", + " new_entry = PoseidonChatLog(question=question, response=response_text)\n", + " new_entry.create()\n", + "\n", + " return jsonify({\"response\": response_text}), 200\n", + " except Exception as e:\n", + " print(\"error!\")\n", + " print(e)\n", + " return jsonify({\"error\": str(e)}), 500 " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Explaintion: \n", + "\n", + "- Class Purpose: GeminiAPI._CRUD provides endpoints for handling requests to a third-party API (Gemini) to generate AI-powered responses for tutors and students.\n", + "\n", + "- POST Method: Sends a request to the Gemini API with user input (e.g., a question or topic). If no input is provided, it returns an error message.\n", + "\n", + "- PUT Method: Updates a previous AI-generated response by sending modified data to the Gemini API, ensuring the request is valid before processing.\n", + "\n", + "- DELETE Method: Deletes a stored AI-generated response by making a request to the Gemini API. If the response ID is not found, it returns an error message.\n", + "\n", + "- GET Method: Retrieves AI-generated content from Gemini based on the given query and returns the response as JSON." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'app' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;129m@app\u001b[39m\u001b[38;5;241m.\u001b[39mroute(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m/api/ai/update\u001b[39m\u001b[38;5;124m'\u001b[39m, methods\u001b[38;5;241m=\u001b[39m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mPUT\u001b[39m\u001b[38;5;124m'\u001b[39m])\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mupdate_ai_question\u001b[39m():\n\u001b[1;32m 3\u001b[0m data \u001b[38;5;241m=\u001b[39m request\u001b[38;5;241m.\u001b[39mget_json()\n\u001b[1;32m 4\u001b[0m old_question \u001b[38;5;241m=\u001b[39m data\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124moldQuestion\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mNameError\u001b[0m: name 'app' is not defined" + ] + } + ], + "source": [ + "@app.route('/api/ai/update', methods=['PUT'])\n", + "def update_ai_question():\n", + " data = request.get_json()\n", + " old_question = data.get(\"oldQuestion\", \"\")\n", + " new_question = data.get(\"newQuestion\", \"\")\n", + "\n", + " if not old_question or not new_question:\n", + " return jsonify({\"error\": \"Both old and new questions are required.\"}), 400\n", + "\n", + " # Fetch the old log\n", + " log = PoseidonChatLog.query.filter_by(_question=old_question).first()\n", + " if not log:\n", + " return jsonify({\"error\": \"Old question not found.\"}), 404\n", + "\n", + " try:\n", + " # Generate a new response for the new question\n", + " response = model.generate_content(f\"Your name is Poseidon, you are a homework help AI chatbot. Only answer homework-related questions. \\nHere is your prompt: {new_question}\")\n", + " new_response = response.text\n", + "\n", + " # Update the database entry\n", + " log._question = new_question\n", + " log._response = new_response\n", + " db.session.commit()\n", + "\n", + " return jsonify({\"response\": new_response}), 200\n", + " except Exception as e:\n", + " print(\"Error during update:\", e)\n", + " return jsonify({\"error\": str(e)}), 500\n", + " \n", + " \n", + " \n", + " @app.route(\"/api/ai/delete\", methods=[\"DELETE\"])\n", + "def delete_ai_chat_logs():\n", + " data = request.get_json()\n", + " if not data:\n", + " return jsonify({\"error\": \"No data provided.\"}), 400\n", + " \n", + " log = PoseidonChatLog.query.filter_by(_question=data.get(\"question\", \"\")).first()\n", + " if not log:\n", + " return jsonify({\"error\": \"Chat log not found.\"}), 404\n", + " \n", + " log.delete()\n", + " return jsonify({\"response\": \"Chat log deleted\"}), 200" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Explanation: \n", + "\n", + "- Class Overview: TopicsAPI._CRUD provides CRUD operations for managing a tutor's topics of expertise, including adding, retrieving, updating, and deleting topics.\n", + "\n", + "- POST Method: Accepts a list of new topics from the request body, adds them to the tutor's current list, and commits the changes to the database.\n", + "\n", + "- GET Method: Retrieves and returns the authenticated tutor's current list of expertise topics in JSON format.\n", + "\n", + "- PUT Method: Replaces the tutor's entire list of topics with a new list provided in the request body and saves the changes.\n", + "\n", + "- DELETE Method: Removes specific topics from the tutor's list of expertise based on the request data and updates the database." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Method/Procedure in Class with Sequencing, Selection, and Iteration " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def restore(chat_data):\n", + " restored_count = 0\n", + " updated_count = 0\n", + " failed_count = 0\n", + " failed_entries = []\n", + "\n", + " if not isinstance(chat_data, list):\n", + " logging.error(\"Invalid chat data format: Expected a list.\")\n", + " return {'message': 'Invalid data format', 'status': 'error'}\n", + "\n", + " try:\n", + " chat_logs_to_add = []\n", + " \n", + " for log_entry in chat_data:\n", + " _ = log_entry.pop('id', None) # Remove 'id' to avoid conflicts\n", + " session_id = log_entry.get(\"session_id\")\n", + "\n", + " if not session_id:\n", + " logging.warning(\"Missing session_id in chat log entry: %s\", log_entry)\n", + " failed_count += 1\n", + " failed_entries.append(log_entry)\n", + " continue\n", + "\n", + " chatlog = ChatLog.query.filter_by(session_id=session_id).first()\n", + "\n", + " if chatlog:\n", + " try:\n", + " chatlog.update(log_entry)\n", + " updated_count += 1\n", + " except Exception as e:\n", + " logging.error(f\"Failed to update chat log {session_id}: {e}\")\n", + " failed_count += 1\n", + " failed_entries.append(log_entry)\n", + " else:\n", + " try:\n", + " chatlog = PoseidonChatLogChatLog(**log_entry)\n", + " chat_logs_to_add.append(chatlog)\n", + " restored_count += 1\n", + " except Exception as e:\n", + " logging.error(f\"Failed to create chat log {session_id}: {e}\")\n", + " failed_count += 1\n", + " failed_entries.append(log_entry)\n", + "\n", + " if chat_logs_to_add:\n", + " db.session.add_all(chat_logs_to_add)\n", + " db.session.commit()\n", + "\n", + " except SQLAlchemyError as e:\n", + " db.session.rollback()\n", + " logging.error(f\"Database error during restore operation: {e}\")\n", + " return {'message': 'Database error occurred', 'status': 'error'}\n", + "\n", + " return {\n", + " 'message': 'Chat logs restored successfully',\n", + " 'restored': restored_count,\n", + " 'updated': updated_count,\n", + " 'failed': failed_count,\n", + " 'failed_entries': failed_entries if failed_count > 0 else None,\n", + " 'status': 'success'\n", + " }" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Explanation: \n", + "\n", + "- Loops through chat_data using a for loop\n", + "\n", + "- Processes each log entry step-by-step\n", + "\n", + "- Uses list accumulation (append()) to track new logs and failures\n", + "\n", + "- Efficiently updates or inserts data based on conditions\n", + "\n", + "- Allows bulk database operations by collecting items first, then committing all at once" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Parameters and Return Type\n", + "\n", + "Parameters:\n", + "\n", + "body: JSON object containing the interest to be deleted.\n", + "\n", + "Return Type:\n", + "\n", + "JSON response with a message indicating the result of the operation.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + " async function deleteItem(itemId) {\n", + " try {\n", + " const response = await fetch(`/delete-item/${itemId}`, {\n", + " method: 'DELETE',\n", + " });\n", + "\n", + " if (response.ok) {\n", + " const result = await response.json();\n", + " alert(result.message);\n", + " const itemElement = document.getElementById(`item-${itemId}`);\n", + " if (itemElement) {\n", + " itemElement.remove();\n", + " }\n", + " } else {\n", + " const error = await response.json();\n", + " alert(`Error: ${error.error}`);\n", + " }\n", + " } catch (error) {\n", + " console.error('Error deleting item:', error);\n", + " alert('An error occurred while deleting the item.');\n", + " }\n", + " }" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Explanation: \n", + "\n", + "- Endpoint Definition & Request URL: The function constructs a DELETE request URL dynamically by appending the itemId to /delete-item/, targeting an API endpoint responsible for handling item deletion in the backend.\n", + "\n", + "- Sending a DELETE Request: The fetch() function is used with the DELETE HTTP method to instruct the backend to remove the specified item from the database.\n", + "\n", + "- Handling API Responses: If the response is successful (response.ok), the function parses the JSON response and displays a success message (result.message). If the response fails, it retrieves the error message from the API and alerts the user.\n", + "\n", + "- Updating the UI After Deletion: If the item exists in the DOM (document.getElementById(\"item-\" + itemId)), it is removed dynamically to reflect the deletion without requiring a page reload.\n", + "\n", + "- Error Handling & Logging: If an exception occurs during the request (e.g., network failure or server issue), the function catches the error, logs it to the console, and alerts the user that the deletion failed." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", + "

Call to Algorithm Request:

\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Definition of Code Block to Make a Request\n", + "\n", + "Frontend Fetch to Endpoint:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + " async function deleteItem(itemId) {\n", + " try {\n", + " const response = await fetch(`/delete-item/${itemId}`, {\n", + " method: 'DELETE',\n", + " });\n", + "\n", + " if (response.ok) {\n", + " const result = await response.json();\n", + " alert(result.message);\n", + " const itemElement = document.getElementById(`item-${itemId}`);\n", + " if (itemElement) {\n", + " itemElement.remove();\n", + " }\n", + " } else {\n", + " const error = await response.json();\n", + " alert(`Error: ${error.error}`);\n", + " }\n", + " } catch (error) {\n", + " console.error('Error deleting item:', error);\n", + " alert('An error occurred while deleting the item.');\n", + " }\n", + " }" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Explanation:\n", + "\n", + "\n", + "- Purpose: The deleteSubject function sends a DELETE request to the /api/subjects endpoint to remove a specific subject from the tutor's list of expertise.\n", + "\n", + "- API Interaction: It includes the subject to be deleted in the request body (formatted as JSON) and uses the fetch API to communicate with the backend.\n", + "\n", + "- Error Handling: If the response is not successful, the function throws an error, logs the issue to the console, and displays an error message to the user.\n", + "\n", + "- Success Feedback: On successful deletion, a success message is displayed to the user (e.g., \"Subject deleted successfully\"), and the tutor's updated information is fetched using the updateTutorInfo() function.\n", + "\n", + "- Global Functionality: The function is assigned to the window object, making it globally accessible and callable from other parts of the application, such as a \"Delete\" button in the UI.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Discuss the Call/Request to the Method with Algorithm\n", + "\n", + "Call/Request:\n", + "\n", + "- The delete function is responsible for sending a DELETE request to the /api/interests endpoint. It includes the specific interest to be removed as part of the request.\n", + "\n", + "Return/Response:\n", + "\n", + "- The response from the backend is handled by checking the status code and updating the UI accordingly." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Handling Data and Error Conditions\n", + "Normal Conditions:\n", + "\n", + "- The interest is successfully deleted, and the UI is updated to reflect the change.\n", + "\n", + "Error Conditions:\n", + "\n", + "- If the interest is not found or the request fails, an error message is displayed." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/homeworkhacks/2024-10-11-HomeworkHacks3.8.ipynb b/_notebooks/homeworkhacks/2024-10-11-HomeworkHacks3.8.ipynb new file mode 100644 index 000000000..a64acaaf3 --- /dev/null +++ b/_notebooks/homeworkhacks/2024-10-11-HomeworkHacks3.8.ipynb @@ -0,0 +1,129 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: 3.8 hacks\n", + "description: Homework Hacks\n", + "permalink: /38/\n", + "comments: true\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The factorial of 10 is 3628800. Impressive how large numbers grow!\n" + ] + } + ], + "source": [ + "#HOMEWORK Hack ONE 3.8.1\n", + "def factorial(n):\n", + " # Base case for factorial of 0 or 1\n", + " if n == 0 or n == 1:\n", + " return 1\n", + " # Check if the input is a valid positive integer\n", + " elif n < 0 or not isinstance(n, int):\n", + " return \"Factorial is not defined for negative numbers or non-integer inputs.\"\n", + " else:\n", + " # Recursive case\n", + " return n * factorial(n - 1)\n", + "\n", + "# Test the function with a number between 9 and 13\n", + "number = 10 # You can change this to any number between 9-13\n", + "result = factorial(number)\n", + "\n", + "# Output the result with a custom message\n", + "if isinstance(result, int):\n", + " print(f\"The factorial of {number} is {result}. Impressive how large numbers grow!\")\n", + "else:\n", + " print(result)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Numbers divisible by 2: [10, 20, 30]. Easy pickings for a quick PopCorn hack!\n" + ] + } + ], + "source": [ + "#PopCorn hack: Find numbers divisible by 2.\n", + "\n", + "def find_divisible_by_2(numbers):\n", + " divisible_by_2 = [num for num in numbers if num % 2 == 0]\n", + " return divisible_by_2\n", + "\n", + "# Example usage\n", + "numbers = [3, 10, 15, 20, 25, 30] # You can input any list of numbers\n", + "result = find_divisible_by_2(numbers)\n", + "\n", + "# Output the result with a custom message\n", + "print(f\"Numbers divisible by 2: {result}. Easy pickings for a quick PopCorn hack!\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "5\n" + ] + } + ], + "source": [ + "#HOMEWORK Hack 3.8.6\n", + "numbers = [1, 2, 3, 4, 5]\n", + "\n", + "# Using a for loop to iterate through the list and print each number\n", + "for number in numbers:\n", + " print(number)\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/homeworkhacks/2024-10-11-HomeworkHacks32.ipynb b/_notebooks/homeworkhacks/2024-10-11-HomeworkHacks32.ipynb new file mode 100644 index 000000000..08830226f --- /dev/null +++ b/_notebooks/homeworkhacks/2024-10-11-HomeworkHacks32.ipynb @@ -0,0 +1,191 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: 3.2 hacks\n", + "description: Homework Hacks\n", + "permalink: /32/\n", + "comments: true\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The sum of 5 and 7 is 12.\n" + ] + } + ], + "source": [ + "#Popcorn Hack: create a simple python script to add two integers\n", + "def add_two_numbers(a, b):\n", + " return a + b\n", + "\n", + "# Example usage\n", + "num1 = 5\n", + "num2 = 7\n", + "\n", + "# Adding the numbers\n", + "result = add_two_numbers(num1, num2)\n", + "\n", + "# Output the result\n", + "print(f\"The sum of {num1} and {num2} is {result}.\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "vscode": { + "languageId": "javascript" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Numbers divisible by 2: [10, 20, 30]. Easy pickings for a quick PopCorn hack!\n" + ] + } + ], + "source": [ + "//Popcorn Hack: create a dictionary, update an item, and add an item\n", + "// Create a dictionary (object)\n", + "let dictionary = {\n", + " apple: \"A fruit that is usually red or green.\",\n", + " banana: \"A long yellow fruit.\",\n", + " orange: \"A round citrus fruit.\"\n", + "};\n", + "\n", + "// Update an item\n", + "dictionary.apple = \"A sweet fruit that is usually red, green, or yellow.\";\n", + "\n", + "// Add a new item\n", + "dictionary.grape = \"A small, round fruit, typically used to make wine.\";\n", + "\n", + "// Output the updated dictionary\n", + "console.log(dictionary);\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "vscode": { + "languageId": "javascript" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "5\n" + ] + } + ], + "source": [ + "//Popcorn Hack: Use JSON to make a dictionary, modify it, and update the changes\n", + "// Step 1: Create a JSON dictionary as a string\n", + "let jsonString = `{\n", + " \"apple\": \"A fruit that is usually red or green.\",\n", + " \"banana\": \"A long yellow fruit.\",\n", + " \"orange\": \"A round citrus fruit.\"\n", + "}`;\n", + "\n", + "// Step 2: Parse the JSON string into a JavaScript object (dictionary)\n", + "let dictionary = JSON.parse(jsonString);\n", + "\n", + "// Step 3: Modify an existing item\n", + "dictionary.apple = \"A sweet fruit that is usually red, green, or yellow.\";\n", + "\n", + "// Step 4: Add a new item\n", + "dictionary.grape = \"A small, round fruit, typically used to make wine.\";\n", + "\n", + "// Step 5: Convert the updated dictionary back to a JSON string\n", + "jsonString = JSON.stringify(dictionary, null, 2); // Pretty print with 2 spaces\n", + "\n", + "// Output the updated JSON string\n", + "console.log(jsonString);\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Original Dictionary:\n", + "{'color': 'blue', 'fruit': 'apple', 'animal': 'dog'}\n", + "\n", + "Updated Dictionary:\n", + "{'name': 'Alice', 'age': 31}\n" + ] + } + ], + "source": [ + "# 1. Create a dictionary with at least 3 keys\n", + "my_dictionary = {\n", + " \"color\": \"blue\",\n", + " \"fruit\": \"apple\",\n", + " \"animal\": \"dog\"\n", + "}\n", + "\n", + "# Print the dictionary\n", + "print(\"Original Dictionary:\")\n", + "print(my_dictionary)\n", + "\n", + "# 2. Start with the given dictionary\n", + "person = {\"name\": \"Alice\", \"age\": 30}\n", + "\n", + "# i. Update the age to 31\n", + "person[\"age\"] = 31\n", + "\n", + "# ii. Print the updated dictionary\n", + "print(\"\\nUpdated Dictionary:\")\n", + "print(person)\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/homeworkhacks/2024-10-16-Blog.ipynb b/_notebooks/homeworkhacks/2024-10-16-Blog.ipynb new file mode 100644 index 000000000..7072aceb1 --- /dev/null +++ b/_notebooks/homeworkhacks/2024-10-16-Blog.ipynb @@ -0,0 +1,93 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: HomeWorkBlog\n", + "description: Homework Blog\n", + "permalink: /hwb/\n", + "comments: true\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "source": [ + "In Big Idea 3 of AP Computer Science Principles, I learned about the impact of computing on our lives, focusing on data, algorithms, and ethics. This unit came with its challenges, but it also taught me a lot.\n", + "\n", + "One major challenge was understanding data representation. It was hard to grasp how data is stored in different formats, like binary. At first, I felt confused, but hands-on activities helped me see how data works in real life. I realized that knowing how to represent data is crucial for everything we do in computing.\n", + "\n", + "Another challenge was working with algorithms. Creating algorithms to solve problems was both fun and tough. I struggled to break down complex problems into smaller steps, but this process taught me how to think more clearly when solving issues. I also learned how to analyze whether my algorithms were efficient, which is an important skill for any programmer.\n", + "\n", + "Discussing ethical considerations in technology was eye-opening. Topics like data privacy and user consent made me think about the responsibilities that come with using technology. I learned that technology can have real-life effects on people, and we must use it responsibly.\n", + "\n", + "Connecting what I learned to real-world applications was also challenging. I had to research how different technologies affect our daily lives, which helped me become more aware of the tools I use every day. This made me realize the importance of being a responsible digital citizen.\n", + "\n", + "Overall, Big Idea 3 had its difficulties, but it gave me a better understanding of how computing affects society. I’ve gained important skills that will help me in the future, and I now see the importance of mixing technical knowledge with ethical thinking." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Homework Descriptions and Encounters\n", + "\n", + "#### [Lesson 1 - Variables](https://yourblogurl.com/314/)\n", + "In this lesson, I learned about variables and their importance in programming. I struggled initially with understanding how to declare and use variables effectively. The biggest challenge was remembering the different data types and their implications. However, I overcame this by creating a reference chart and practicing with small coding exercises, which helped solidify my understanding of variable scope and usage.\n", + "\n", + "#### [Lesson 2 - Data Abstraction](https://yashpatil321.github.io/yash1_2025/32/)\n", + "This lesson introduced the concept of data abstraction and how it simplifies complex problems. I faced difficulties in grasping how to use abstraction to hide unnecessary details while focusing on relevant information. After discussing examples with my peers and working on abstraction exercises, I became more comfortable with the idea of creating simplified models that improved my programming efficiency.\n", + "\n", + "#### [Lesson 3 - Math Expressions](https://yashpatil321.github.io/yash1_2025/335/)\n", + "In this lesson, I explored math expressions and their role in programming. I initially struggled with order of operations and how to implement them correctly in code. By practicing with various expressions and breaking down complex calculations step-by-step, I developed a better understanding of how to use math expressions effectively in my programs.\n", + "\n", + "#### [Lesson 4 - Strings](https://yourblogurl.com/335/)\n", + "This lesson focused on string manipulation and how to use strings in programming. I encountered challenges when trying to understand string functions and their applications. At first, it was difficult to remember the syntax for different string operations. Through hands-on practice and creating small projects that utilized string manipulation, I became more proficient in handling strings in my code.\n", + "\n", + "#### [Lesson 5 - Booleans](https://yashpatil321.github.io/yash1_2025/354/)\n", + "In this assignment, I learned about Boolean values and their significance in controlling program flow. I found it challenging to understand how Boolean logic works, particularly in conjunction with conditional statements. After working through several logical exercises and testing my understanding through quizzes, I gained confidence in using Boolean expressions to make decisions in my programs.\n", + "\n", + "#### [Lesson 6 - Conditionals](https://yashpatil321.github.io/yash1_2025/374/)\n", + "This lesson introduced me to conditional statements and their role in decision-making within programs. I initially struggled with writing clear and concise conditional statements, especially when incorporating multiple conditions. However, after practicing with flowcharts and pseudocode, I improved my ability to visualize and implement conditionals effectively in my projects.\n", + "\n", + "#### [Lesson 7 - Nested Conditionals](https://yashpatil321.github.io/yash1_2025/374/)\n", + "In this lesson, I delved deeper into nested conditionals and their complexities. I encountered challenges in understanding how to properly structure nested statements without creating confusion in my code. Through collaborative coding exercises and peer feedback, I learned to write more organized nested conditionals, which enhanced the functionality of my programs.\n", + "\n", + "#### [Lesson 8 - Iteration](https://yashpatil321.github.io/yash1_2025/38/)\n", + "This final lesson focused on iteration and the use of loops in programming. I struggled with understanding when to use different types of loops (for vs. while) and how to control their execution. By experimenting with various loop scenarios and visualizing the flow of my code, I became more confident in using iteration to automate repetitive tasks and improve my coding efficiency.\n", + "\n", + "#### [Lesson 10 - Lesson I Helped Create](https://nighthawkcoders.github.io/portfolio_2025/csp/big-idea/p3/3-10-1)\n", + "This final lesson focused on iteration and the use of loops in programming. I struggled with understanding when to use different types of loops (for vs. while) and how to control their execution. By experimenting with various loop scenarios and visualizing the flow of my code, I became more confident in using iteration to automate repetitive tasks and improve my coding efficiency.\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/homeworkhacks/2024-10-7-Javascriptvariables314.ipynb b/_notebooks/homeworkhacks/2024-10-7-Javascriptvariables314.ipynb new file mode 100644 index 000000000..ccf30a679 --- /dev/null +++ b/_notebooks/homeworkhacks/2024-10-7-Javascriptvariables314.ipynb @@ -0,0 +1,123 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: 3.1.4 Javascript Hacks\n", + "description: Homework Hacks\n", + "permalink: /314/\n", + "comments: true\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Yash Patil, aged 15, can be contacted at yashp.d39@gmailcom and has a balance of $1500.0 in his account.\n" + ] + } + ], + "source": [ + "#HACK ONE\n", + "# Step 1: Assign values to the user profile variables\n", + "full_name = \"Yash Patil\"\n", + "age = 15\n", + "email = \"yashp.d39@gmailcom\"\n", + "account_balance = 1500.00\n", + "\n", + "# Step 2: Display the information\n", + "print(f\"{full_name}, aged {age}, can be contacted at {email} and has a balance of ${account_balance} in his account.\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The store has 10 units of Ipads priced at $1200.0 each.\n", + "The store has 25 units of Iphones priced at $800.0 each.\n" + ] + } + ], + "source": [ + "#HACK TWO\n", + "# Step 1: Assign values for the first product\n", + "product_name1 = \"Ipad\"\n", + "product_price1 = 1200.00\n", + "product_stock1 = 10\n", + "\n", + "# Step 2: Assign values for the second product\n", + "product_name2 = \"Iphone\"\n", + "product_price2 = 800.00\n", + "product_stock2 = 25\n", + "\n", + "# Step 3: Output a message describing each product's stock and price\n", + "print(f\"The store has {product_stock1} units of {product_name1}s priced at ${product_price1} each.\")\n", + "print(f\"The store has {product_stock2} units of {product_name2}s priced at ${product_price2} each.\")\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The total price for 3 items each priced at $20.0 with a tax rate of 10.0% is $66.00.\n" + ] + } + ], + "source": [ + "#HACK 3\n", + "# Step 1: Assign values for item price, quantity, and tax rate\n", + "itemPrice = 20.00\n", + "quantity = 3\n", + "taxRate = 0.10 # 10% tax\n", + "\n", + "# Step 2: Calculate the total price after tax\n", + "totalPriceBeforeTax = itemPrice * quantity\n", + "totalPriceAfterTax = totalPriceBeforeTax * (1 + taxRate)\n", + "\n", + "# Step 3: Output the result\n", + "print(f\"The total price for {quantity} items each priced at ${itemPrice} with a tax rate of {taxRate*100}% is ${totalPriceAfterTax:.2f}.\")\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/homeworkhacks/2024-10-7-Pythonvariable312.ipynb b/_notebooks/homeworkhacks/2024-10-7-Pythonvariable312.ipynb new file mode 100644 index 000000000..1a766c4c0 --- /dev/null +++ b/_notebooks/homeworkhacks/2024-10-7-Pythonvariable312.ipynb @@ -0,0 +1,123 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: 3.1.2 Python Hacks\n", + "description: Homework Hacks\n", + "permalink: /312/\n", + "comments: true\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Step 1: Value = 42, Type = \n", + "Step 2: Value = 'Hello, world!', Type = \n", + "Step 3: Value = [1, 2, 3], Type = \n", + "Step 4: Value = True, Type = \n" + ] + } + ], + "source": [ + "#HACK ONE\n", + "#step1 define variables\n", + "my_var = 42\n", + "print(f\"Step 1: Value = {my_var}, Type = {type(my_var)}\") # Prints: int\n", + "\n", + "#step2 reassign new types\n", + "my_var = \"Hello, world!\"\n", + "print(f\"Step 2: Value = '{my_var}', Type = {type(my_var)}\") # Prints: str\n", + "\n", + "#step3 reassign to another type\n", + "my_var = [1, 2, 3]\n", + "print(f\"Step 3: Value = {my_var}, Type = {type(my_var)}\") # Prints: list\n", + "\n", + "#step4: reassign to a boolean\n", + "my_var = True\n", + "print(f\"Step 4: Value = {my_var}, Type = {type(my_var)}\") # Prints: bool\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#HACK TWO\n", + "# Step 1: Initialize variables\n", + "a = 5\n", + "b = 10\n", + "\n", + "# Step 2: Swap values without using a temporary variable\n", + "a, b = b, a # Python allows tuple unpacking for variable swapping\n", + "\n", + "# Step 3: Print the swapped values\n", + "print(\"a =\", a) # Output: a = 10\n", + "print(\"b =\", b) # Output: b = 5\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "x and y are stored at the same memory address: 140061043526992\n" + ] + } + ], + "source": [ + "#HACK 3\n", + "# Step 1: Assign the same value to two variables\n", + "x = 100\n", + "y = 100\n", + "\n", + "# Step 2: Compare memory addresses\n", + "same_memory = id(x) == id(y)\n", + "\n", + "# Step 3: Print whether they are stored at the same location\n", + "if same_memory:\n", + " print(f\"x and y are stored at the same memory address: {id(x)}\")\n", + "else:\n", + " print(f\"x and y are stored at different memory addresses: x = {id(x)}, y = {id(y)}\")\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/homeworkhacks/2024-10-8-Javascripthacks344.ipynb b/_notebooks/homeworkhacks/2024-10-8-Javascripthacks344.ipynb new file mode 100644 index 000000000..add5c5a92 --- /dev/null +++ b/_notebooks/homeworkhacks/2024-10-8-Javascripthacks344.ipynb @@ -0,0 +1,179 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: 3.4.4 Javascript Hacks\n", + "description: Homework Hacks\n", + "permalink: /344/\n", + "comments: true\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dlroW olleH\n" + ] + } + ], + "source": [ + "#HACK ONE\n", + "def reverse_string(input_string):\n", + " return input_string[::-1] # Slicing method to reverse the string\n", + "\n", + "# Example usage\n", + "print(reverse_string(\"Hello World\")) # Output: \"dlroW olleH\"\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n" + ] + } + ], + "source": [ + "#HACK TWO\n", + "def count_vowels(input_string):\n", + " vowels = 'aeiouAEIOU'\n", + " return sum(1 for char in input_string if char in vowels)\n", + "\n", + "# Example usage\n", + "print(count_vowels(\"Hello World\")) # Output: 3" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "xyzdexyz\n" + ] + } + ], + "source": [ + "#HACK 3\n", + "def replace_abc_with_xyz(input_string):\n", + " return input_string.replace('abc', 'xyz')\n", + "\n", + "# Example usage\n", + "print(replace_abc_with_xyz(\"abcdeabc\")) # Output: \"xyzdexyz\"\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], + "source": [ + "#HACK 4\n", + "import string\n", + "\n", + "def is_palindrome(input_string):\n", + " cleaned_string = ''.join(char.lower() for char in input_string if char.isalnum()) # Remove spaces, punctuation\n", + " return cleaned_string == cleaned_string[::-1]\n", + "\n", + "# Example usage\n", + "print(is_palindrome(\"A man, a plan, a canal, Panama\")) # Output: True" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "quick\n" + ] + } + ], + "source": [ + "#HACK 5\n", + "def find_longest_word(sentence):\n", + " words = sentence.split()\n", + " longest_word = max(words, key=len)\n", + " return longest_word\n", + "\n", + "# Example usage\n", + "print(find_longest_word(\"The quick brown fox jumps over the lazy dog\")) # Output: \"jumps\"\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n" + ] + } + ], + "source": [ + "#HACK 6\n", + "import re\n", + "\n", + "def sum_of_numbers_in_string(input_string):\n", + " numbers = re.findall(r'\\d+', input_string) # Find all numbers in the string\n", + " return sum(int(num) for num in numbers)\n", + "\n", + "# Example usage\n", + "print(sum_of_numbers_in_string(\"I have 2 apples and 3 bananas, total 5.\")) # Output: 10" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/homeworkhacks/2024-10-8-Javascripthacks362.ipynb b/_notebooks/homeworkhacks/2024-10-8-Javascripthacks362.ipynb new file mode 100644 index 000000000..bb5955726 --- /dev/null +++ b/_notebooks/homeworkhacks/2024-10-8-Javascripthacks362.ipynb @@ -0,0 +1,178 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: 3.4.4 Javascript Hacks\n", + "description: Homework Hacks\n", + "comments: true\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dlroW olleH\n" + ] + } + ], + "source": [ + "#HACK ONE\n", + "def reverse_string(input_string):\n", + " return input_string[::-1] # Slicing method to reverse the string\n", + "\n", + "# Example usage\n", + "print(reverse_string(\"Hello World\")) # Output: \"dlroW olleH\"\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n" + ] + } + ], + "source": [ + "#HACK TWO\n", + "def count_vowels(input_string):\n", + " vowels = 'aeiouAEIOU'\n", + " return sum(1 for char in input_string if char in vowels)\n", + "\n", + "# Example usage\n", + "print(count_vowels(\"Hello World\")) # Output: 3" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "xyzdexyz\n" + ] + } + ], + "source": [ + "#HACK 3\n", + "def replace_abc_with_xyz(input_string):\n", + " return input_string.replace('abc', 'xyz')\n", + "\n", + "# Example usage\n", + "print(replace_abc_with_xyz(\"abcdeabc\")) # Output: \"xyzdexyz\"\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], + "source": [ + "#HACK 4\n", + "import string\n", + "\n", + "def is_palindrome(input_string):\n", + " cleaned_string = ''.join(char.lower() for char in input_string if char.isalnum()) # Remove spaces, punctuation\n", + " return cleaned_string == cleaned_string[::-1]\n", + "\n", + "# Example usage\n", + "print(is_palindrome(\"A man, a plan, a canal, Panama\")) # Output: True" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "quick\n" + ] + } + ], + "source": [ + "#HACK 5\n", + "def find_longest_word(sentence):\n", + " words = sentence.split()\n", + " longest_word = max(words, key=len)\n", + " return longest_word\n", + "\n", + "# Example usage\n", + "print(find_longest_word(\"The quick brown fox jumps over the lazy dog\")) # Output: \"jumps\"\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n" + ] + } + ], + "source": [ + "#HACK 6\n", + "import re\n", + "\n", + "def sum_of_numbers_in_string(input_string):\n", + " numbers = re.findall(r'\\d+', input_string) # Find all numbers in the string\n", + " return sum(int(num) for num in numbers)\n", + "\n", + "# Example usage\n", + "print(sum_of_numbers_in_string(\"I have 2 apples and 3 bananas, total 5.\")) # Output: 10" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/homeworkhacks/2024-10-9-BooleanHacks354.ipynb b/_notebooks/homeworkhacks/2024-10-9-BooleanHacks354.ipynb new file mode 100644 index 000000000..c79c5b514 --- /dev/null +++ b/_notebooks/homeworkhacks/2024-10-9-BooleanHacks354.ipynb @@ -0,0 +1,154 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: 3.5 Boolean hacks\n", + "description: Homework Hacks\n", + "permalink: /354/\n", + "comments: true\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "True\n", + "True\n" + ] + } + ], + "source": [ + "#HACKS ONE PYTHON\n", + "def goOutside(temperature, isRaining):\n", + " if temperature < 100 and isRaining:\n", + " return True\n", + " elif temperature > 32 and not isRaining:\n", + " return True\n", + " else:\n", + " return False\n", + "\n", + "# Example usage\n", + "print(goOutside(95, True)) # Output: True\n", + "print(goOutside(33, False)) # Output: True\n", + "print(goOutside(101, False)) # Output: False\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "vscode": { + "languageId": "javascript" + } + }, + "outputs": [], + "source": [ + "//HACKS ONE JS\n", + "\n", + "function goOutside(temperature, isRaining) {\n", + " if (temperature < 100 && isRaining === true) {\n", + " return true;\n", + " } else if (temperature > 32 && isRaining === false) {\n", + " return true;\n", + " } else {\n", + " return false;\n", + " }\n", + "}\n", + "\n", + "// Example usage\n", + "console.log(goOutside(95, true)); // Output: true\n", + "console.log(goOutside(33, false)); // Output: true\n", + "console.log(goOutside(101, false)); // Output: false" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#HACKS TWO PYTHON\n", + "\n", + "# Expression 1: Original and simplified using De Morgan's Law\n", + "stayInside1 = not (isRaining and isCold)\n", + "# Simplified version\n", + "stayInside1 = not isRaining or not isCold\n", + "\n", + "# Expression 2: Original and simplified using De Morgan's Law\n", + "stayInside2 = not (isRaining or isCold)\n", + "# Simplified version\n", + "stayInside2 = not isRaining and not isCold\n", + "\n", + "# Example values\n", + "isRaining = True\n", + "isCold = False\n", + "\n", + "print(stayInside1) # Output: True\n", + "print(stayInside2) # Output: False\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "vscode": { + "languageId": "javascript" + } + }, + "outputs": [], + "source": [ + "//HACKS TWO JS\n", + "\n", + "// Expression 1: Original and simplified using De Morgan's Law\n", + "let stayInside1 = !(isRaining && isCold);\n", + "// Simplified version\n", + "stayInside1 = !isRaining || !isCold;\n", + "\n", + "// Expression 2: Original and simplified using De Morgan's Law\n", + "let stayInside2 = !(isRaining || isCold);\n", + "// Simplified version\n", + "stayInside2 = !isRaining && !isCold;\n", + "\n", + "// Example values\n", + "let isRaining = true;\n", + "let isCold = false;\n", + "\n", + "console.log(stayInside1); // Output: true\n", + "console.log(stayInside2); // Output: false\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/homeworkhacks/2024-10-9-HomeworkHacks374.ipynb b/_notebooks/homeworkhacks/2024-10-9-HomeworkHacks374.ipynb new file mode 100644 index 000000000..a70e35832 --- /dev/null +++ b/_notebooks/homeworkhacks/2024-10-9-HomeworkHacks374.ipynb @@ -0,0 +1,118 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: 3.7.4 hacks\n", + "description: Homework Hacks\n", + "permalink: /374/\n", + "comments: true\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You are not eligible to vote.\n" + ] + } + ], + "source": [ + "#HOMEWORK QUESTION ONE\n", + "# Get user age and determine if they are eligible to vote\n", + "age = int(input(\"Please enter your age: \"))\n", + "\n", + "if age >= 18:\n", + " print(\"You are eligible to vote.\")\n", + "else:\n", + " print(\"You are not eligible to vote.\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You should eat an apple!\n" + ] + } + ], + "source": [ + "#HOMEWORK QUESTION ONE\n", + "\n", + "# Get user health status\n", + "health_status = input(\"Are you healthy, unhealthy, or indifferent about food? (healthy/unhealthy/indifferent): \").strip().lower()\n", + "\n", + "if health_status == \"healthy\":\n", + " print(\"You should eat an apple!\")\n", + "else:\n", + " if health_status == \"unhealthy\":\n", + " print(\"You should eat chocolate!\")\n", + " else:\n", + " print(\"You don't care about what you eat. How about a coffee?\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You should eat an apple!\n" + ] + } + ], + "source": [ + "#HOMEWORK QUESTION 3\n", + "# Get user health status\n", + "health_status = input(\"Are you healthy, unhealthy, or indifferent about food? (healthy/unhealthy/indifferent): \").strip().lower()\n", + "\n", + "if health_status == \"healthy\":\n", + " print(\"You should eat an apple!\")\n", + "elif health_status == \"unhealthy\":\n", + " print(\"You should eat chocolate!\")\n", + "elif health_status == \"indifferent\":\n", + " print(\"You don't care about what you eat. How about a coffee?\")\n", + "else:\n", + " print(\"Invalid input! Please enter 'healthy', 'unhealthy', or 'indifferent'.\")\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/homeworkhacks/2024-10-9-Homeworkhacks335.ipynb b/_notebooks/homeworkhacks/2024-10-9-Homeworkhacks335.ipynb new file mode 100644 index 000000000..05433c120 --- /dev/null +++ b/_notebooks/homeworkhacks/2024-10-9-Homeworkhacks335.ipynb @@ -0,0 +1,99 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "layout: post\n", + "title: 3.3.5 Homework Hacks\n", + "description: Homework Hacks\n", + "permalink: /335/\n", + "comments: true\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "#HACK ONE\n", + "# Adds 2 parameters\n", + "def add(a, b):\n", + " return a + b\n", + "\n", + "# Subtracts 2 parameters\n", + "def subtract(a, b):\n", + " return a - b\n", + "\n", + "# Divides 2 parameters\n", + "def divide(a, b):\n", + " return a / b if b != 0 else \"Cannot divide by zero\"\n", + "\n", + "# Finds the Modulus of 2 parameters\n", + "def modulus(a, b):\n", + " return a % b\n", + "\n", + "# Raises parameter A to the power of parameter B\n", + "def power(a, b):\n", + " return a ** b" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "15\n", + "5\n", + "5.0\n", + "1\n", + "8\n", + "22\n" + ] + } + ], + "source": [ + "#HACK TWO\n", + "# Hack 2: Finds a point on the graph of f(x) = 5x + 2\n", + "def find_point(x):\n", + " return 5 * x + 2\n", + "\n", + "# Example calls for testing\n", + "print(add(10, 5)) # Output: 15\n", + "print(subtract(10, 5)) # Output: 5\n", + "print(divide(10, 2)) # Output: 5.0\n", + "print(modulus(10, 3)) # Output: 1\n", + "print(power(2, 3)) # Output: 8\n", + "print(find_point(4)) # Output: 22" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_posts/Foundation/A-pair_programming/2024-12-9-PosideonHomeworkBot.md b/_posts/Foundation/A-pair_programming/2024-12-9-PosideonHomeworkBot.md new file mode 100644 index 000000000..c91a4eab2 --- /dev/null +++ b/_posts/Foundation/A-pair_programming/2024-12-9-PosideonHomeworkBot.md @@ -0,0 +1,104 @@ +--- +toc: true +layout: post +title: Gemini API Posidon AI Chatbot +description: This is for the assignment and notes +permalink: /posts/api +comments: True +--- + + +[**link to python flask notebook**](_posts/2024-12-02-python-flask_in_jupyter_IPYNB_2_.md) + +## Step Two (yash.py) + +This is my personal /api file that routes to /api/nolan and returns the information about me. + +### Backend Code +```python +from flask import Blueprint, request, jsonify, g +from flask_restful import Api, Resource + +yash_api = Blueprint('yash_api', __name__, url_prefix='/api') +api = Api(yash_api) + +class YashAPI: + class _Y_Person(Resource): + def get(self): + return jsonify({ + "name": "Yash Patil", + "age": 16, + "classes": ["Advanced Placement Computer Science Principles", "Advance Placement English Seminar 1", "Advance Placement AP Calculus AB", "World History Two"], + "favorite": { + "color": "Green", + "number": 21 + } + }) + + +api.add_resource(YashAPI._Y_Person, "/yash") +``` +### Postman + +postman of Yash's api + +### backend Code + +```python + +genai.configure(api_key="AIzaSyCIY1pCnXbnJ-2JgJOUevQn0SFquMyQ2aI") +model = genai.GenerativeModel('gemini-pro') + +@app.route('/api/ai/help', methods=['POST']) +def ai_homework_help(): + data = request.get_json() + question = data.get("question", "") + if not question: + return jsonify({"error": "No question provided."}), 400 + + try: + response = model.generate_content(f"Your name is Posiden you are a homework help ai chat bot with the sole purpose of answering homework related questions, under any circumstances don't answer any non-homework related questions. \nHere is your prompt: {question}") + return jsonify({"response": response.text}), 200 + except Exception as e: + print("error!") + print(e) + return jsonify({"error": str(e)}), 500 + +``` + +**It contains one route:** + +1. **POST - /api/ai/help** + This route accepts a user's question and generates an AI response using the **Gemini-Pro AI model**. + + **Example Request:** + + ```json + { + "question": "What is Newton's third law of motion?" + } + +Example Response data: + +{ + "response": "Newton's third law states that for every action, there is an equal and opposite reaction." +} + +Error Handling: +If there is an issue with the AI model or the request payload, the API will return an error response. +Example error response: + +{ + "error": "No question provided." +} + +### video + + + +### Post Photo + +postman of gemini api \ No newline at end of file diff --git a/images/1.png b/images/1.png new file mode 100644 index 000000000..1d10b5232 Binary files /dev/null and b/images/1.png differ diff --git a/images/12.png b/images/12.png new file mode 100644 index 000000000..4ad480f71 Binary files /dev/null and b/images/12.png differ diff --git a/images/2.png b/images/2.png new file mode 100644 index 000000000..08103de33 Binary files /dev/null and b/images/2.png differ diff --git a/images/23.png b/images/23.png new file mode 100644 index 000000000..e2d7e0657 Binary files /dev/null and b/images/23.png differ diff --git a/images/3.png b/images/3.png new file mode 100644 index 000000000..d084ecd6e Binary files /dev/null and b/images/3.png differ diff --git a/images/34.png b/images/34.png new file mode 100644 index 000000000..3fa800fe7 Binary files /dev/null and b/images/34.png differ diff --git a/images/4.png b/images/4.png new file mode 100644 index 000000000..f87f266da Binary files /dev/null and b/images/4.png differ diff --git a/images/5.png b/images/5.png new file mode 100644 index 000000000..81479978b Binary files /dev/null and b/images/5.png differ diff --git a/images/Screenshot 2024-12-17 104427.png b/images/Screenshot 2024-12-17 104427.png new file mode 100644 index 000000000..6fa690098 Binary files /dev/null and b/images/Screenshot 2024-12-17 104427.png differ diff --git a/images/Screenshot 2024-12-17 105540.png b/images/Screenshot 2024-12-17 105540.png new file mode 100644 index 000000000..f0b94a26a Binary files /dev/null and b/images/Screenshot 2024-12-17 105540.png differ diff --git a/images/Screenshot 2024-12-28 113821.png b/images/Screenshot 2024-12-28 113821.png new file mode 100644 index 000000000..0df285cf0 Binary files /dev/null and b/images/Screenshot 2024-12-28 113821.png differ diff --git a/images/backendtable.png b/images/backendtable.png new file mode 100644 index 000000000..69f81d44c Binary files /dev/null and b/images/backendtable.png differ diff --git a/images/deca.jpg b/images/deca.jpg new file mode 100644 index 000000000..ee5cbbd44 Binary files /dev/null and b/images/deca.jpg differ diff --git a/images/figma.png b/images/figma.png new file mode 100644 index 000000000..80cc4f023 Binary files /dev/null and b/images/figma.png differ diff --git a/images/image.png b/images/image.png new file mode 100644 index 000000000..a311cdb18 Binary files /dev/null and b/images/image.png differ diff --git a/images/kanban.png b/images/kanban.png new file mode 100644 index 000000000..1883097c2 Binary files /dev/null and b/images/kanban.png differ diff --git a/images/ntmdeca.jpg b/images/ntmdeca.jpg new file mode 100644 index 000000000..328d11c7e Binary files /dev/null and b/images/ntmdeca.jpg differ diff --git a/index.md b/index.md index c5006b98c..1e1263bb8 100644 --- a/index.md +++ b/index.md @@ -1,8 +1,140 @@ --- layout: base -title: Student Home +title: Home description: Home Page hide: true --- -My journey starts here. + + + +## Submenu + +## Gaming Submenu + + + + + + + + +
+

This is a button

+ + + + +
+ Journey +
+ +

Click on these to see my Liverpool FC and Journey pages

+
+ + +Mario walking + + + + + diff --git a/navigation/IMG_0526.jpg b/navigation/IMG_0526.jpg new file mode 100644 index 000000000..393f5e5db Binary files /dev/null and b/navigation/IMG_0526.jpg differ diff --git a/navigation/about.md b/navigation/about.md index a8d98630a..943e3ba10 100644 --- a/navigation/about.md +++ b/navigation/about.md @@ -3,5 +3,52 @@ layout: page title: About permalink: /about/ --- +![Yash Patil](IMG_0526.jpg) +# About Me -Creator of Student 2025 +Hello! I'm Yash Patil, a driven 15-year-old sophomore at Del Norte High School in San Diego, California. My passion for business innovation and technology fuels my ambition to make a significant impact in the world of startups and tech solutions. With a strong desire to learn and grow, I'm constantly seeking new challenges and opportunities to develop my skills and knowledge. + +## My Journey + +From a young age, I've been fascinated by the power of technology and its ability to transform industries. This curiosity led me to co-found **GoLocal Web Business**, a venture dedicated to helping small businesses establish a robust online presence. We specialize in building custom websites, utilizing CRM software, and employing social media strategies to help our clients expand their reach and achieve their business goals. + +During this journey, I’ve gained valuable experience in: +- **Marketing:** Crafting strategies that resonate with target audiences and drive engagement. +- **Business Development:** Identifying growth opportunities and building relationships with potential clients. +- **Cold Calling:** Reaching out to local businesses to pitch our services and secure new clients. +- **Web Design:** Creating visually appealing and user-friendly websites tailored to the unique needs of each business. + +## Projects and Achievements + +In addition to GoLocal Web Business, I've been involved in various other projects that reflect my commitment to making a difference. One of these is **Needz4Teens**, an organization aimed at providing essential resources to teens in shelters. This initiative has allowed me to combine my entrepreneurial skills with a passion for social impact, ensuring that vulnerable teens receive the support they need. + +## Personal Interests + +Outside of my professional pursuits, I have a deep love for sports, particularly soccer. Playing soccer not only keeps me active but also teaches me valuable lessons in teamwork, discipline, and perseverance. I'm also a passionate fan of Liverpool FC, always cheering them on during matches. + +## Looking Ahead + +As I continue my journey, I am very eager to explore new avenues in business and technology. I believe that the combination of innovation, dedication, and a willingness to learn is key to success. Whether it's through further education, internships, or entrepreneurial ventures, I'm excited to see where my passions will take me. + +Connect with me on [LinkedIn](https://www.linkedin.com/in/yashpatil21/) to explore potential collaborations, share ideas, or just chat about the latest in business and technology! + +## Skills +- **Marketing** 📈: Expertise in digital marketing, content creation, and campaign management. +- **Business Development** 💼: Proven ability to identify opportunities and build strategic partnerships. +- **Cold Calling** 📞: Effective communication and persuasion skills to generate leads and close deals. +- **Web Design** 💻: Proficient in creating responsive, SEO-friendly websites using modern design principles. + + + +## Languages +- **English:** Native or Bilingual Proficiency +- **Hindi:** Full Professional Proficiency + +## Contact Information +- **Email:** [golocalwebbusiness@gmail.com](mailto:golocalwebbusiness@gmail.com) +- **LinkedIn:** [Yash Patil](https://www.linkedin.com/in/yashpatil21/) + +I'm always open to new opportunities, so don't hesitate to reach out! +![India](https://upload.wikimedia.org/wikipedia/en/thumb/4/41/Flag_of_India.svg/1200px-Flag_of_India.svg.png) + +![USA](https://cdn.britannica.com/79/4479-050-6EF87027/flag-Stars-and-Stripes-May-1-1795.jpg) \ No newline at end of file diff --git a/navigation/blog.md b/navigation/blog.md index 0ce56306d..54d141069 100644 --- a/navigation/blog.md +++ b/navigation/blog.md @@ -4,3 +4,44 @@ title: Blogs search_exclude: true permalink: /blogs/ --- + +# Reflecting on My MCQ Performance: Strengths and Ways to Improve + +Hi, I’m Yash, and recently in CSP I took a multiple-choice quiz on programming and computer science. It covered a lot of different topics, and I learned a lot about what I’m good at and what I need to work on. Here’s a quick summary of how it went and what I can do to improve. + +--- + +## What I Did Well + +I was happy to see that I did really well in some areas: +- **Data Abstraction (100%)**: I’m good at simplifying complex problems by breaking them into smaller parts. +- **Developing Procedures (100%)**: I feel confident designing reusable blocks of code, which helps make programs more organized. +- **Libraries and Crowdsourcing (100%)**: I understand how to use external resources and collaborate to solve problems. + +I also did well in tasks that require organizing my code, like **developing programs with abstractions (78%)**, which shows I have a solid foundation. + +--- + +## What I Need to Improve + +The quiz also showed me where I need to focus more: +- **Conditionals and Boolean Expressions (33%-50%)**: I struggled with creating and understanding logical conditions in programs. +- **Using Programs with Data (43%)**: Working with data, like extracting or organizing it, was tough for me. +- **Developing Algorithms (36%)**: This was my weakest area. I need more practice building efficient solutions to problems. + +--- + +## How I’ll Improve + +Here’s my plan to get better: +1. **Practice Weak Areas**: I’ll practice conditionals, data handling, and algorithms using online coding platforms like LeetCode or Khan Academy. +2. **Build Small Projects**: I’ll create projects that involve working with data and writing algorithms to apply what I’ve learned. +3. **Review Regularly**: I’ll go over tricky topics every week to make sure I really understand them. +4. **Debugging Practice**: I’ll use debugging tools to track errors in my code, especially for logical conditions. + +--- + +## Final Thoughts + +This quiz was a great way to see what I know and where I need to improve. Even though some parts were hard, I’m excited to keep learning and getting better. With more practice, I know I can turn my weak spots into strengths. + diff --git a/navigation/contact.md b/navigation/contact.md new file mode 100644 index 000000000..71e7bd45b --- /dev/null +++ b/navigation/contact.md @@ -0,0 +1,29 @@ +--- +layout: base +title: Contact +description: Liverpool FC Contact Information +--- + + + +

Contact Liverpool FC

+ +

Club Contact Information

+ +

Address:
+ Liverpool Football Club
+ Anfield Road,
+ Liverpool, L4 0TH, England

+ +

Main Switchboard: +44 151 263 2361

+ +

Ticket Office / Booking Line: +44 843 170 5555

+ +

Customer Services / Memberships: +44 843 170 5000

+ +

Email: contact@example.com

diff --git a/navigation/gamingnotebook1.md b/navigation/gamingnotebook1.md new file mode 100644 index 000000000..6124eb6a2 --- /dev/null +++ b/navigation/gamingnotebook1.md @@ -0,0 +1,201 @@ +--- +layout: base +title: Advanced Cookie Clicker +--- + +# Advanced Cookie Clicker Game 🍪 + +Click the cookie to earn points! Upgrade your clicking power and buy auto-clickers to generate cookies automatically. + +
+ Cookie +

Cookies Collected: 0

+ +

Upgrades

+
+
+
+ + +

Stats

+

Cookies Per Click: 1

+

Auto Clicker Owned: 0

+

Grandma Owned: 0

+

Factory Owned: 0

+ + +

Achievements

+

+
+ + + + diff --git a/navigation/gamingnotebook2.md b/navigation/gamingnotebook2.md new file mode 100644 index 000000000..cb1e8e54c --- /dev/null +++ b/navigation/gamingnotebook2.md @@ -0,0 +1,67 @@ +--- +layout: base +title: Binary Calculator +--- + +# Decimal to Binary Calculator + + + + + + Decimal to Binary Calculator + + + + +

Decimal to Binary Calculator

+ + +
+ +

+ + + +

+ + + +

+ + + +
+ + +

Result (Binary):

+ + + + + + + diff --git a/navigation/gamingnotebook3.md b/navigation/gamingnotebook3.md new file mode 100644 index 000000000..a6564c2ac --- /dev/null +++ b/navigation/gamingnotebook3.md @@ -0,0 +1,368 @@ +--- +layout: base +title: Snake Game +--- + + + +
+
+

Snake score: 0

+
+
+ + + +
+

Game Over, press space to try again

+ new game + settings +
+ + + +
+

Settings Screen, press space to go back to playing

+ new game +
+

Speed: + + + + + + +

+

Wall: + + + + +

+
+
+
+ + \ No newline at end of file diff --git a/navigation/history.md b/navigation/history.md new file mode 100644 index 000000000..b63eab178 --- /dev/null +++ b/navigation/history.md @@ -0,0 +1,30 @@ +--- +layout: base +title: History +description: Liverpool FC History +--- + + + +

Liverpool FC History

+ +

Liverpool Football Club was founded in 1892 and has become one of the most successful football clubs in history. With 19 league titles and 6 European Cups, Liverpool's rich history is filled with unforgettable moments.

+ +

Key Historical Moments

+ +

Kenny Dalglish (1977)

+Kenny Dalglish +

Signed from Celtic for £440,000, Dalglish became one of Liverpool's greatest players and later its manager.

+ +

Ian Rush (1980)

+Ian Rush +

Rush joined from Chester City and became Liverpool's all-time top scorer with 346 goals.

+ +

Virgil van Dijk (2018)

+Virgil van Dijk +

Signed for a record £75 million, Van Dijk's arrival solidified Liverpool's defense and helped lead them to Champions League and Premier League glory.

diff --git a/navigation/journey.md b/navigation/journey.md new file mode 100644 index 000000000..fd0a8ca5d --- /dev/null +++ b/navigation/journey.md @@ -0,0 +1,43 @@ +--- +layout: base +title: Journey +description: journey Page +--- + +# Yash Patil's Journey + +## About Me +Hello! I’m Yash Patil, a sophomore at Del Norte High School, passionate about business and technology. My goal is to create innovative solutions that help small businesses and drive social impact. + +## My Learning Journey + +### Setting Up My GitHub Pages Blog + +As part of my learning journey, I followed the setup process for creating my own blogging website on GitHub Pages. Here’s an overview of the steps I took: + +1. **Linux Terminal and Shell Commands**: + - Used commands like `ls`, `pwd`, and `cd` to navigate and manage folders. + - Learned how to run version control commands like `git clone` to set up a local project. + +2. **Version Control with Git**: + - Mastered essential commands such as `git pull`, `git commit`, and `git push` to update, save, and sync changes with my GitHub repository. + +3. **Package Management**: + - Installed key tools and frameworks using `apt-get` on Linux and `brew` on macOS, ensuring my development environment was properly set up. + +4. **Starting the Project**: + - Created a directory for my project and cloned the repository. + - Activated a virtual environment to manage Python dependencies. + - Built a local server using the `make` command to test my changes before deploying them. + +5. **VSCode Workflow**: + - Opened my project in VSCode and used the built-in source control tools to stage, commit, and sync changes with GitHub. + - Ensured my GitHub Pages site automatically updated with the latest changes. + +## Achievements +- **GoLocal Web Business**: Co-founded a business to help local businesses with web design and CRM solutions. +- **Needz4Teens**: Created an initiative to support teens in shelters by providing essential resources. + +## Interests +In addition to tech, I love playing soccer and following Liverpool FC. Soccer has taught me teamwork and perseverance, which I apply in my projects. + diff --git a/navigation/liverpool.md b/navigation/liverpool.md new file mode 100644 index 000000000..8dcaffb66 --- /dev/null +++ b/navigation/liverpool.md @@ -0,0 +1,64 @@ +--- +layout: base +title: Liverpool FC +description: Official Liverpool FC Home Page +--- + + + + +

Liverpool Football Club

+Liverpool FC Crest + +

Welcome to Liverpool FC

+

Founded in 1892, Liverpool FC is one of the most iconic and successful football clubs in the world. Our home is the legendary Anfield stadium, where we continue to make history.

+ +

Latest News

+ + +## Anfield Stadium + +![Anfield Stadium](https://www.leisureopportunities.co.uk/images/572951_28864.jpg) + +

Anfield is the historic home of Liverpool Football Club, known for its incredible atmosphere and passionate fans. Located in the heart of Liverpool, the stadium has been the club's home since its formation in 1892.

+ +

Key Facts:

+
    +
  • Capacity: 53,394
  • +
  • Opened: 1884 (Liverpool's home since 1892)
  • +
  • Famous Stand: The Kop, known for its powerful chants and support
  • +
  • Unique Feature: "You'll Never Walk Alone" anthem sung before every match
  • +
  • Significant Matches: Numerous iconic European nights, including Liverpool’s 4-0 victory over Barcelona in the 2019 Champions League semi-final
  • +
+ + +

Liverpool FC Jokes

+
+

Click the button to hear a Liverpool-themed joke:

+ +

+
+ + diff --git a/navigation/notebook1.md b/navigation/notebook1.md new file mode 100644 index 000000000..98ecbc7e6 --- /dev/null +++ b/navigation/notebook1.md @@ -0,0 +1,96 @@ +--- +layout: base +title: JavaScript Shell +--- + +# JavaScript Shell + +**Welcome to the JavaScript Shell!** Here's a Liverpool-themed trivia game to test your knowledge! + + +

Liverpool FC Trivia Game

+
+

Test your knowledge with our Liverpool FC trivia game:

+ +
+

+
+
+ + + +

+
+ + diff --git a/navigation/notebook2.md b/navigation/notebook2.md new file mode 100644 index 000000000..9913ff31d --- /dev/null +++ b/navigation/notebook2.md @@ -0,0 +1,91 @@ +--- +layout: base +title: Messi VS. Ronaldo +--- + +# Messi VS. Ronaldo + +Welcome to the ultimate football debate: Lionel Messi vs. Cristiano Ronaldo. Both players are legends of the game, but who is the greatest of all time? Let's dive into their stats, achievements, and more to see how they compare. + +## Lionel Messi + +### Photo +![Lionel Messi](https://cdn.britannica.com/35/238335-050-2CB2EB8A/Lionel-Messi-Argentina-Netherlands-World-Cup-Qatar-2022.jpg) + +### Career Facts +- **Full Name:** Lionel Andrés Messi +- **Date of Birth:** June 24, 1987 +- **Nationality:** Argentine +- **Position:** Forward +- **Current Club:** Inter Miami (as of 2024) +- **Previous Club:** FC Barcelona, Paris Saint-Germain +- **Ballon d'Or Awards:** 7 +- **Top Scorer:** FC Barcelona +- **Notable Achievements:** + - 4x UEFA Champions League Winner + - 10x La Liga Champion + - 2022 FIFA World Cup Winner + +### Notable Records +- **Most Goals in a Calendar Year:** 91 (2012) +- **Most Goals in La Liga:** 474 + +### Playing Style +Messi is renowned for his exceptional dribbling, vision, and playmaking abilities. His low center of gravity and quick acceleration make him a formidable opponent in one-on-one situations. + +## Cristiano Ronaldo + +### Photo +![Cristiano Ronaldo](https://lncimg.lance.com.br/cdn-cgi/image/width=828,quality=75,fit=pad,format=webp/uploads/2021/06/23/60d38e1fc5e92.jpeg) + +### Career Facts +- **Full Name:** Cristiano Ronaldo dos Santos Aveiro +- **Date of Birth:** February 5, 1985 +- **Nationality:** Portuguese +- **Position:** Forward +- **Current Club:** Al-Nassr (as of 2024) +- **Previous Clubs:** Sporting CP, Manchester United, Real Madrid, Juventus +- **Ballon d'Or Awards:** 5 +- **Top Scorer:** Real Madrid +- **Notable Achievements:** + - 5x UEFA Champions League Winner + - 3x Premier League Champion + - 1x UEFA European Championship Winner + +### Notable Records +- **Most Goals in UEFA Champions League:** 135 +- **Most Goals for Portugal National Team:** 123 + +### Playing Style +Ronaldo is celebrated for his incredible athleticism, powerful shooting, and heading ability. His speed and physicality make him a significant threat in both aerial duels and counter-attacks. + +## Head-to-Head Comparison + +| Category | Lionel Messi | Cristiano Ronaldo | +|-----------------------------|-------------------------|------------------------| +| **Ballon d'Or Awards** | 7 | 5 | +| **UEFA Champions League Wins** | 4 | 5 | +| **Career Goals** | Over 800 | Over 900 | +| **World Cup Wins** | 1 | 0 | +| **UEFA European Championship Wins** | 0 | 1 | + +## Achievements and Legacy + +### Messi's Legacy +Messi's career is marked by extraordinary consistency and loyalty, particularly during his time at FC Barcelona. His ability to influence the game through both scoring and assisting has set numerous records. + +### Ronaldo's Legacy +Ronaldo's career is characterized by his adaptability and success across multiple leagues. His physical prowess and goal-scoring ability have earned him admiration globally. + +## Conclusion + +Both Lionel Messi and Cristiano Ronaldo have left indelible marks on football history. Their contrasting styles and records make them two of the greatest players ever to grace the pitch. While Messi's magic and creativity enchant fans, Ronaldo's power and precision captivate spectators around the world. + +Who do you think is the greatest? Share your thoughts and join the debate! + +--- + +### Additional Resources +- [Lionel Messi Official Website](https://www.lionelmessi.com) +- [Cristiano Ronaldo Official Website](https://www.cristianoronaldo.com) +- [UEFA Champions League Statistics](https://www.uefa.com/uefachampionsleague/) diff --git a/navigation/notebook3.md b/navigation/notebook3.md new file mode 100644 index 000000000..f72612a0e --- /dev/null +++ b/navigation/notebook3.md @@ -0,0 +1,80 @@ +--- +layout: base +title: Text to Binary +--- + +--- +layout: base +title: Text to Binary +--- + +# Text to Binary Converter + +Welcome to the Text to Binary Converter page! Here you can convert text into binary code using a simple program. Below is the JavaScript code that performs this conversion. + +## JavaScript Code + + + + + Text to Binary Converter + + + + +
+

Text to Binary Converter

+ + +

+
+ + + + + diff --git a/navigation/players.md b/navigation/players.md new file mode 100644 index 000000000..8aa520aca --- /dev/null +++ b/navigation/players.md @@ -0,0 +1,93 @@ +--- +layout: base +title: Players +description: Liverpool FC Squad 2024/25 +--- + + +

Liverpool FC Main Squad 2024/25

+ +

Goalkeepers

+ +### Alisson Becker +Alisson Becker +- **Number:** 1 +- **Nationality:** Brazil +- **Age:** 31 +- **Contract until:** June 30, 2027 +- **Market value:** €28.00m +- Alisson is regarded as one of the best goalkeepers globally, with exceptional shot-stopping and distribution skills. + +### Caoimhin Kelleher +Caoimhin Kelleher +- **Number:** 62 +- **Nationality:** Republic of Ireland +- **Age:** 25 +- **Contract until:** June 30, 2026 +- **Market value:** €20.00m +- Kelleher is a talented young goalkeeper and backup to Alisson, showing great promise in cup competitions. + +

Defenders

+ +### Virgil van Dijk +Virgil van Dijk +- **Number:** 4 +- **Nationality:** Netherlands +- **Age:** 33 +- **Contract until:** June 30, 2025 +- **Market value:** €30.00m +- Van Dijk is a key leader at the back and the team captain, with commanding defensive performances. + +### Trent Alexander-Arnold +Trent Alexander-Arnold +- **Number:** 66 +- **Nationality:** England +- **Age:** 25 +- **Contract until:** June 30, 2025 +- **Market value:** €70.00m +- A dynamic right-back known for his passing and creativity. + +

Midfielders

+ +### Dominik Szoboszlai +Dominik Szoboszlai +- **Number:** 8 +- **Nationality:** Hungary +- **Age:** 23 +- **Contract until:** June 30, 2028 +- **Market value:** €75.00m +- A fan favorite, known for his technical ability and work rate in midfield. + +### Alexis Mac Allister +Alexis Mac Allister +- **Number:** 10 +- **Nationality:** Argentina +- **Age:** 25 +- **Contract until:** June 30, 2028 +- **Market value:** €75.00m +- A versatile midfielder and World Cup winner with Argentina. + +

Forwards

+ +### Mohamed Salah +Mohamed Salah +- **Number:** 11 +- **Nationality:** Egypt +- **Age:** 32 +- **Contract until:** June 30, 2025 +- **Market value:** €55.00m +- Liverpool's star forward, known for his pace, dribbling, and scoring ability. + +### Darwin Núñez +Darwin Núñez +- **Number:** 9 +- **Nationality:** Uruguay +- **Age:** 25 +- **Contract until:** June 30, 2028 +- **Market value:** €70.00m +- A dynamic striker with great pace and aerial ability. diff --git a/navigation/super-mario-64-mario-png-new-super-mario-bros-2-mario-11562902957fdyjsvoiwq.png b/navigation/super-mario-64-mario-png-new-super-mario-bros-2-mario-11562902957fdyjsvoiwq.png new file mode 100644 index 000000000..5cbf1746e Binary files /dev/null and b/navigation/super-mario-64-mario-png-new-super-mario-bros-2-mario-11562902957fdyjsvoiwq.png differ diff --git a/navigation/transfers.md b/navigation/transfers.md new file mode 100644 index 000000000..ddd340cf0 --- /dev/null +++ b/navigation/transfers.md @@ -0,0 +1,36 @@ +--- +layout: base +title: Transfers +description: Liverpool FC Transfer News and Speculations +--- + + +

Liverpool FC Transfers 2024/25

+ +

Incoming Transfers

+ +### Federico Chiesa +Federico Chiesa +- **Transfer Fee:** £10.7 million plus add-ons +- **Position:** Winger or outside midfielder +- **Strengths:** Dribbling, progressive passing, direct play +- Chiesa will provide cover for Mo Salah and add creativity to Liverpool's attack. + +### Giorgi Mamardashvili +Giorgi Mamardashvili +- **Position:** Goalkeeper +- Details of the transfer are still emerging, but the Valencia goalkeeper is expected to become Liverpool's first summer signing. + +

Outgoing Transfers

+ +### Joe Gomez +Joe Gomez +- Gomez has been linked with a move away from Liverpool after being left out of recent match-day squads. + +

Transfer Window Overview

+- Under new manager Arne Slot, Liverpool is focused on adding depth and creativity to the squad while offloading players to make room for new signings.