diff --git a/main.ipynb b/main.ipynb index 73f285a..817c8ef 100644 --- a/main.ipynb +++ b/main.ipynb @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -37,19 +37,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def greater(a,b):\n", + " return a if a > b else b\n", " pass" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.137s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_greater(greater)" @@ -64,19 +77,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "def greatest(arr):\n", - " pass" + " max_=arr[0]\n", + " for num in arr:\n", + " if max_ < num:\n", + " max_ = num\n", + " return(max_)" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.140s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_greatest(greatest)" @@ -91,19 +120,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "def sum_all(arr):\n", - " pass" + " numsum=0\n", + " for num in arr:\n", + " numsum += num\n", + " return numsum" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.171s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_sum(sum_all)" @@ -118,19 +162,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "def mult_all(arr):\n", - " pass" + " nummulti=(1)\n", + " for num in arr:\n", + " nummulti *= num\n", + " return nummulti" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.196s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_mult(mult_all)" @@ -145,19 +204,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "def oper_all(arr, oper):\n", - " pass" + " if oper == \"+\":\n", + " numsum=0\n", + " for num in arr:\n", + " numsum += num \n", + " return numsum\n", + " elif oper == \"*\":\n", + " nummulti=(1)\n", + " for num in arr:\n", + " nummulti *= num\n", + " return nummulti" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.159s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_operations(oper_all)" @@ -172,19 +252,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "def factorial(n):\n", - " pass" + " f=1\n", + " if n >= 1:\n", + " for num in range(1, n+1):\n", + " f=f*num\n", + " return f\n", + " \n", + " elif n == 0:\n", + " return 1" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.169s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_factorial(factorial)" @@ -201,19 +300,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "def unique(arr):\n", - " pass" + " numun=0\n", + " list_=[]\n", + " for num in arr:\n", + " numun = num\n", + " if numun == num:\n", + " list_.append(num)\n", + " return list_" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.182s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_unique(unique)" @@ -229,12 +346,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "ename": "IndentationError", + "evalue": "expected an indented block (658186893.py, line 3)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m Input \u001b[1;32mIn [16]\u001b[1;36m\u001b[0m\n\u001b[1;33m \u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n" + ] + } + ], "source": [ "def mode_counter(arr):\n", - " pass" + " for num in arr:\n", + " " ] }, { @@ -263,7 +390,21 @@ "source": [ "from statistics import stdev\n", "def st_dev(arr):\n", - " pass" + " #STDEV = SUM OF (INDIVIDUAL VALUE - AVERAGE OF THE VALUES)/TOTAL NUMBER OF VALUES\n", + " \n", + " #AVERAGE OF THE VALUES = SUM OF ALL NUMBERS / TOTAL NUMBER OF VALUES\n", + " #---------------------------------------------------------------------\n", + " # This is the sum of all the numbers in the array\n", + " numsum=0\n", + " tot={}\n", + " for s in arr:\n", + " numsum += s #numsum is the total addition\n", + " if t in tot:\n", + " tot[t]=1\n", + " # This is the total number of values\n", + "\n", + " \n", + "st_dev([1,2,3,4])" ] }, { @@ -285,19 +426,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "def pangram(string):\n", - " pass" + " alphabet=(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\")\n", + " stringlist=[]\n", + " string = string.replace(\" \",\"\").lower()\n", + "\n", + " for i in string:\n", + " if i.isalpha():\n", + " stringlist.append(i)\n", + " \n", + " stringlist = set(sorted(stringlist))\n", + "\n", + " if stringlist == set(alphabet): \n", + " return True\n", + " else:\n", + " return False" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "..............................\n", + "----------------------------------------------------------------------\n", + "Ran 30 tests in 0.048s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_pangram(pangram)" @@ -314,19 +480,43 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid character '“' (U+201C) (1848529017.py, line 3)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m Input \u001b[1;32mIn [25]\u001b[1;36m\u001b[0m\n\u001b[1;33m string+=“,”\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid character '“' (U+201C)\n" + ] + } + ], "source": [ "def sort_alpha(string):\n", - " pass" + "\n", + "\n", + "\n", + "sort_alpha(\"dsaop,dsac,delab,edhsa,acbg\")" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.232s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_alpha(sort_alpha)" @@ -342,14 +532,37 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 76, + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'int' object is not callable", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "Input \u001b[1;32mIn [76]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m a\u001b[38;5;241m=\u001b[39mcount(i)\n\u001b[0;32m 8\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m a\n\u001b[1;32m----> 9\u001b[0m \u001b[43mcheck_pass\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43maB123456789!\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "Input \u001b[1;32mIn [76]\u001b[0m, in \u001b[0;36mcheck_pass\u001b[1;34m(string)\u001b[0m\n\u001b[0;32m 2\u001b[0m count\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m string:\n\u001b[1;32m----> 6\u001b[0m a\u001b[38;5;241m=\u001b[39m\u001b[43mcount\u001b[49m\u001b[43m(\u001b[49m\u001b[43mi\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 8\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m a\n", + "\u001b[1;31mTypeError\u001b[0m: 'int' object is not callable" + ] + } + ], "source": [ "def check_pass(string):\n", - " pass" + "\n", + " for i in string:\n", + " for \n", + "check_pass(\"aB123456789!\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -363,7 +576,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -377,7 +590,20 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.6" + "version": "3.9.13" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4,