From a51edb545c89dbaed4e0cd4aed9738f70b9f26f3 Mon Sep 17 00:00:00 2001 From: Mara Date: Wed, 8 Oct 2025 17:49:14 +0200 Subject: [PATCH] initial commit --- main.ipynb | 815 ++++++++++++++++++++++-- mod/__pycache__/testing.cpython-312.pyc | Bin 0 -> 19668 bytes 2 files changed, 764 insertions(+), 51 deletions(-) create mode 100644 mod/__pycache__/testing.cpython-312.pyc diff --git a/main.ipynb b/main.ipynb index b05630a..b1b2b48 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,36 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "def greater(a,b):\n", - "#your code here" + " if a > b:\n", + " return a\n", + " elif b > a:\n", + " return b\n", + " else:\n", + " print(\"The numbers are equal!\")\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.234s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_greater(greater)" @@ -59,9 +76,21 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "100" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "#your code here" + "#selftest\n", + "greater(100,1)" ] }, { @@ -73,23 +102,61 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ - "#your code here" + "#your code here\n", + "def greatest(lista):\n", + " largest_element = None\n", + " for element in lista:\n", + " if largest_element is None or largest_element < element:\n", + " largest_element = element\n", + " return largest_element\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.156s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_greatest(greatest)" ] }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1502" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "greatest(lista = [15, 110, 1502, 6, 58, 48])" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -99,26 +166,85 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "def sum_all(lst):\n", - "#your code here" + " sum = 0\n", + " for num in lst:\n", + " sum += num\n", + " return sum\n", + " " ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.189s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_sum(sum_all)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1739" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#selftest\n", + "sum_all(lst = [15, 110, 1502, 6, 58, 48])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1739" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#selftest with build-in function\n", + "lst = [15, 110, 1502, 6, 58, 48]\n", + "sum(lst)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -133,21 +259,57 @@ "outputs": [], "source": [ "def mult_all(lst):\n", - "#your code here" + " product = 1\n", + " for i in lst:\n", + " product = product * i\n", + " return product\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.204s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_mult(mult_all)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "41397523200" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#selftest\n", + "mult_all(lst)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -157,24 +319,72 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 40, "metadata": {}, "outputs": [], "source": [ "def oper_all(arr, oper = \"*\"):\n", - "#your code here" + " if oper == \"+\":\n", + " total = 0\n", + " for i in arr:\n", + " total += i\n", + " elif oper == \"*\":\n", + " total = 1\n", + " for i in arr:\n", + " total = total * i\n", + " return total\n", + " \n", + " \n", + "\n", + "\n", + "\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 41, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.269s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_operations(oper_all)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "601" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#selftest\n", + "\n", + "listc = [110,51,58,6,325,51]\n", + "oper_all(listc, \"+\")" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -184,12 +394,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 47, "metadata": {}, "outputs": [], "source": [ "def factorial(n):\n", - "#your code here" + " fact = 1\n", + " for x in range(1, n+1):\n", + " fact *= x\n", + " return fact\n", + "\n" ] }, { @@ -213,14 +427,48 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 48, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.198s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_factorial(factorial)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "720" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#selftest \n", + "\n", + "factorial(6)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -232,24 +480,65 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 51, "metadata": {}, "outputs": [], "source": [ "def unique(lst_un):\n", - "#your code here" + " un_lst = []\n", + " for val in lst_un:\n", + " if val not in un_lst:\n", + " un_lst.append(val)\n", + " return un_lst\n", + "\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 52, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.368s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_unique(unique)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[12, 15, 2, 5]" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#selftest \n", + "\n", + "ran_lst = [12, 12, 12, 15, 15, 2, 5, 5]\n", + "\n", + "unique(ran_lst)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -260,24 +549,76 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 60, "metadata": {}, "outputs": [], "source": [ "def mode_counter(arr):\n", - "#your code here" + " freqs = {}\n", + " for x in arr:\n", + " if x not in freqs:\n", + " freqs[x] = 1\n", + " else:\n", + " freqs[x] += 1\n", + " mode = None\n", + " max_count = 0\n", + " for i in freqs:\n", + " if freqs[i] > max_count:\n", + " mode = i\n", + " max_count = freqs[i]\n", + " return mode\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "......." + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + ".............................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.210s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_mode(mode_counter)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "12" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# selftest \n", + "mode_counter(ran_lst)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -288,19 +629,109 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 76, "metadata": {}, "outputs": [], "source": [ "def st_dev(list_sd):\n", - "#your code here" + " total = 0\n", + " sum = 0\n", + " for x in list_sd:\n", + " total += 1\n", + " sum += x\n", + "\n", + " mean = sum/total\n", + "\n", + " sum_sqr_dev = 0\n", + " for x in list_sd:\n", + " dev = x - mean\n", + " sum_sqr_dev += dev*dev\n", + "\n", + " var = sum_sqr_dev/(total - 1)\n", + " sd_dev = var ** 0.5\n", + "\n", + " return sd_dev\n", + "\n", + "\n", + "# Standard Deviation:\n", + "# 1. calculate mean = sum/total\n", + "# 2. substract mean from each data point, dev = x - mean\n", + "# 3. square deviation, (dev)^2\n", + "# 4. sum sqr dev, sum((dev)^2)\n", + "# 5. calculate variance, var = sum sqr dev / total\n", + "# 6. find square root, sqr root(var)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "295.9241832331758" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#check wits build-in function: \n", + "\n", + "list_sd = [15, 44, 47, 48, 11, 532, 896, 51, 24, 145]\n", + "\n", + "stdev(list_sd)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "295.9241832331758" + ] + }, + "execution_count": 78, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#selftest\n", + "\n", + "st_dev(list_sd)" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....." + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "...............................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.120s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_stdev(st_dev)" @@ -320,14 +751,185 @@ "outputs": [], "source": [ "def pangram(string):\n", - "#your code here" + " has_lower = False\n", + " #has_upper = False\n", + "\n", + " string = string.lower()\n", + "\n", + " for char in string:\n", + " if char == \"a\" and char == \"b\" and char == \"c\" and char == \"d\" and char == \"e\" and char == \"f\" and char == \"g\" and char == \"h\" and char == \"i\" and char == \"j\" and char == \"k\" and char == \"l\" and char == \"m\" and char == \"n\" and char == \"o\" and char == \"p\" and char == \"q\" and char == \"r\" and char == \"s\" and char == \"t\" and char == \"u\" and char == \"v\" and char == \"w\" and char == \"x\" and char == \"y\" and char == \"z\":\n", + " has_lower = True\n", + " #if char == \"A\" and char == \"B\" and char == \"C\" and char == \"D\" and char == \"E\" and char == \"F\" and char == \"G\" and char == \"H\" and char == \"I\" and char == \"J\" and char == \"K\" and char == \"L\" and char == \"M\" and char == \"N\" and char == \"O\" and char == \"P\" and char == \"Q\" and char == \"R\" and char == \"S\" and char == \"T\" and char == \"U\" and char == \"V\" and char == \"W\" and char == \"X\" and char == \"Y\" and char == \"Z\":\n", + " #has_upper = True\n", + "\n", + " if has_lower: #and has_upper:\n", + " return True \n", + " else:\n", + " return False \n", + " \n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 99, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "FFFFFFFFFFFFFFF..F...F....F...\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "======================================================================\n", + "FAIL: runTest (mod.testing.test_pangram..TestKnown.runTest)\n", + "----------------------------------------------------------------------\n", + "Traceback (most recent call last):\n", + " File \"c:\\Users\\black\\Documents\\Ironhack\\Week_1\\Day3\\lab-functions-en\\mod\\testing.py\", line 172, in runTest\n", + " self.assertEqual(fn(self.input), self.output, f\"Should be {self.output}\")\n", + "AssertionError: False != True : Should be True\n", + "\n", + "----------------------------------------------------------------------\n", + "Ran 30 tests in 0.068s\n", + "\n", + "FAILED (failures=18)\n" + ] + } + ], "source": [ "# This will test your function \n", "test_pangram(pangram)" @@ -349,19 +951,79 @@ "outputs": [], "source": [ "def sort_alpha(string):\n", - "#your code here" + " sorted_lst = [\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\",]\n", + " words = 0\n", + "\n", + " for char in string:\n", + " if char == \",\":\n", + " words += 1\n", + " else:\n", + " sorted_lst[words] = sorted_lst[words] + char\n", + "\n", + "\n", + " sorted_lst = sorted(sorted_lst)\n", + "\n", + " result = \"\"\n", + " first = True\n", + "\n", + " for word in sorted_lst:\n", + " if word != \"\":\n", + " if not first:\n", + " result = result + \",\"\n", + " result = result + word\n", + " first = False\n", + "\n", + " return result\n", + "\n", + "# need to fix, that first word is being integrated as well " ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 126, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.204s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_alpha(sort_alpha)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "' alpine, my, number, x,hello'" + ] + }, + "execution_count": 127, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#selftest \n", + "\n", + "strg = \"hello, my, alpine, x, number\"\n", + "\n", + "sort_alpha(strg)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -376,23 +1038,79 @@ "outputs": [], "source": [ "def check_pass(password):\n", - "#your code here" + " length = 0\n", + " has_lower = False\n", + " has_upper = False\n", + " has_digit = False\n", + " has_spechar = False\n", + "\n", + " for char in password:\n", + " length += 1\n", + " if char == \"a\" or char == \"b\" or char == \"c\" or char == \"d\" or char == \"e\" or char == \"f\" or char == \"g\" or char == \"h\" or char == \"i\" or char == \"j\" or char == \"k\" or char == \"l\" or char == \"m\" or char == \"n\" or char == \"o\" or char == \"p\" or char == \"q\" or char == \"r\" or char == \"s\" or char == \"t\" or char == \"u\" or char == \"v\" or char == \"w\" or char == \"x\" or char == \"y\" or char == \"z\":\n", + " has_lower = True\n", + " if char == \"A\" or char == \"B\" or char == \"C\" or char == \"D\" or char == \"E\" or char == \"F\" or char == \"G\" or char == \"H\" or char == \"I\" or char == \"J\" or char == \"K\" or char == \"L\" or char == \"M\" or char == \"N\" or char == \"O\" or char == \"P\" or char == \"Q\" or char == \"R\" or char == \"S\" or char == \"T\" or char == \"U\" or char == \"V\" or char == \"W\" or char == \"X\" or char == \"Y\" or char == \"Z\":\n", + " has_upper = True\n", + " if char == \"0\" or char == \"1\" or char == \"2\" or char == \"3\" or char == \"4\" or char == \"5\" or char == \"6\" or char == \"7\" or char == \"8\" or char == \"9\":\n", + " has_digit = True\n", + " if char == \"!\" or char == \"@\" or char == \"#\" or char == \"$\" or char == \"%\" or char == \"?\" or char == \"&\" or char == \"(\" or char == \")\" or char == \"{\" or char == \"}\" or char == \"^\" or char == \"*\" or char == \"+\" or char == \"[\" or char == \"]\":\n", + " has_spechar = True\n", + "\n", + " if length >= 8 and has_lower and has_upper and has_digit and has_spechar:\n", + " return True \n", + " else:\n", + " return False \n", + "\n", + "\n", + "# comment: probably not working for all password cases, as the special characters list could be definietly longer" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.143s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_pass(check_pass)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 88, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#selftest\n", + "check_pass(\"hJI0[kdowßlS76\")" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Ironhack", "language": "python", "name": "python3" }, @@ -406,12 +1124,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" - }, - "vscode": { - "interpreter": { - "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" - } + "version": "3.12.11" } }, "nbformat": 4, diff --git a/mod/__pycache__/testing.cpython-312.pyc b/mod/__pycache__/testing.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b5a9df00754193be004b2fb9e53912f0a4b1cf95 GIT binary patch literal 19668 zcmeHPdr(wYn!oqQ!MF}P|8677IL`6Xq5YvL4OW)hjO+U!J-2yE* zOjT-wvnD39nbJuzyRf<|Y^;jzxTUkZRf|bx*VLve-P2H}dNMVC?AGq`pCg%_F|}3M z?>qO=54w5Gki^u?t?IAOIrqFDzwbNW`Of|Kyu2I=p8sC^UtK?ADe6Daqdtt{m>B`b z1&XJ5+C$mof7(WapYbqWolQq$n9ig38f*sQ)_aWJEL)b>WHS-J!ISOHvE_JkZMj~v z%?x427b#mFp9R#yn}Fu?*+2{U9H7hiT%gN&Gtd=$9?+G%1?VH46rcasw5^aY0N*Np z8PL`Ia-fg))7BN!SltFI9W#moA9M)d%64*&fM0ZR9xD?wNC93r71MkDykOPE@;S-j za@jrpUO{wllAs0zdwP@rBk$^T1tbTJ87mL=mJWV1JrMd5^^)NN#ZddGVZ$)xWO({T z6VC+HxRhJ%K`n%$-p17MeBThz@^$OwutfT{;u)j^S!y`1ds|6UL$xF%ogzcka-CvsX*bxv@yf9Iv_UPFyo|o z=0%fDKTP$}HbWC-)qS=uAV>jwrzmg%L9E#2@jEz=w7a4iLJ#`k zlY%Z#@i9KD8=zi>5mH-0Qv>t>Wml_44KU!-^6IC?>4tGV%*7zgvY5$kcllfayFF%b z`FetZn9&~$!2h@*rk4bdQ(O+^iCA(hTdP?t+irJwI7zbGB?G)-S$1gXvwFw3+FB$* zl-fExoTIy~#_tGv1z$jFJ0SXfT^Q6V2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