diff --git a/GROUP 15/GROUP MEMBERS.txt b/GROUP 15/GROUP MEMBERS.txt new file mode 100644 index 0000000..a57fce2 --- /dev/null +++ b/GROUP 15/GROUP MEMBERS.txt @@ -0,0 +1,8 @@ + GROUP 15 +OKPU VICTORY CHUKWUNEKU - ENG2403558 +OGBEBOR DAVID OBOSA - ENG2403549 +UDUEHI BENJAMIN IMOKHAI - ENG2403575 +MBACHU OBIAGELI VICTORIA - ENG2403539 +JEGEDE CHARITY OLABODE - ENG2403535 +IKUOBASE EMMANUEL OSAMUDIAMEN – ENG2307438 +ONUWAJE ORITSEBAWO DAVID - ENG2403563 \ No newline at end of file diff --git a/GROUP 15/Group 15 Quadractic Equqtion assignment.ipynb b/GROUP 15/Group 15 Quadractic Equqtion assignment.ipynb new file mode 100644 index 0000000..478146d --- /dev/null +++ b/GROUP 15/Group 15 Quadractic Equqtion assignment.ipynb @@ -0,0 +1,159 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "id": "3f225d47", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Quadratic Equation Solver\n", + "Result: ('Complex', (-0.6666666666666666+0.7453559924999299j), (-0.6666666666666666-0.7453559924999299j))\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "def solve_quadratic(a, b, c):\n", + " \"\"\"Solve quadratic equation ax^2 + bx + c = 0.\"\"\"\n", + " if a == 0:\n", + " raise ValueError(\"Coefficient 'a' cannot be zero for a quadratic equation.\")\n", + " \n", + " discriminant = b**2 - 4*a*c\n", + " \n", + " if discriminant > 0:\n", + " root1 = (-b + math.sqrt(discriminant)) / (2*a)\n", + " root2 = (-b - math.sqrt(discriminant)) / (2*a)\n", + " return (\"Real and Distinct\", root1, root2)\n", + " elif discriminant == 0:\n", + " root = -b / (2*a)\n", + " return (\"Real and Equal\", root)\n", + " else:\n", + " real_part = -b / (2*a)\n", + " imag_part = math.sqrt(-discriminant) / (2*a)\n", + " return (\"Complex\", complex(real_part, imag_part), complex(real_part, -imag_part))\n", + "\n", + "\n", + "if __name__ == \"__main__\":\n", + " print(\"Quadratic Equation Solver\")\n", + " a = float(input(\"Enter a: \"))\n", + " b = float(input(\"Enter b: \"))\n", + " c = float(input(\"Enter c: \"))\n", + "\n", + " try:\n", + " result = solve_quadratic(a, b, c)\n", + " print(\"Result:\", result)\n", + " except ValueError as e:\n", + " print(\"Error:\", e)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "c0a353a4", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "y = ax^2 + bx + c\n", + "no solution!!\n" + ] + }, + { + "ename": "ImportError", + "evalue": "cannot import name 'solve_quadratic' from 'quadratic' (C:\\Users\\johnh\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\quadratic.py)", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mImportError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpytest\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mquadratic\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m solve_quadratic \u001b[38;5;66;03m# assuming your main file is quadratic.py\u001b[39;00m\n\u001b[32m 4\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mtest_real_distinct\u001b[39m():\n\u001b[32m 5\u001b[39m \u001b[38;5;28;01massert\u001b[39;00m solve_quadratic(\u001b[32m1\u001b[39m, -\u001b[32m5\u001b[39m, \u001b[32m6\u001b[39m) == (\u001b[33m\"\u001b[39m\u001b[33mReal and Distinct\u001b[39m\u001b[33m\"\u001b[39m, \u001b[32m3.0\u001b[39m, \u001b[32m2.0\u001b[39m)\n", + "\u001b[31mImportError\u001b[39m: cannot import name 'solve_quadratic' from 'quadratic' (C:\\Users\\johnh\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\quadratic.py)" + ] + } + ], + "source": [ + "import pytest\n", + "from quadratic import solve_quadratic # assuming your main file is quadratic.py\n", + "\n", + "def test_real_distinct():\n", + " assert solve_quadratic(1, -5, 6) == (\"Real and Distinct\", 3.0, 2.0)\n", + "\n", + "def test_real_equal():\n", + " assert solve_quadratic(1, 2, 1) == (\"Real and Equal\", -1.0)\n", + "\n", + "def test_complex_roots():\n", + " result = solve_quadratic(1, 0, 1)\n", + " assert result[0] == \"Complex\"\n", + " assert result[1] == complex(0.0, 1.0)\n", + " assert result[2] == complex(0.0, -1.0)\n", + "\n", + "def test_invalid_a():\n", + " with pytest.raises(ValueError):\n", + " solve_quadratic(0, 2, 1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8a655028", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "60e18dfa", + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'quadratics' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mNameError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28;01massert\u001b[39;00m (\u001b[43mquadratics\u001b[49m(\u001b[32m1\u001b[39m,\u001b[32m4\u001b[39m,\u001b[32m1\u001b[39m)) == () \n", + "\u001b[31mNameError\u001b[39m: name 'quadratics' is not defined" + ] + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0624c66e", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/GROUP 15/Quadratic_Report_Group15.docx b/GROUP 15/Quadratic_Report_Group15.docx new file mode 100644 index 0000000..ad2569e Binary files /dev/null and b/GROUP 15/Quadratic_Report_Group15.docx differ diff --git a/GROUP 15/Untitled Diagram.drawio.html b/GROUP 15/Untitled Diagram.drawio.html new file mode 100644 index 0000000..89765b0 --- /dev/null +++ b/GROUP 15/Untitled Diagram.drawio.html @@ -0,0 +1,12 @@ + + + +
+