From 1deceb852906e2ad70685da7dc1573ecdffff6c6 Mon Sep 17 00:00:00 2001 From: sborto86 Date: Thu, 6 Oct 2022 17:56:22 +0200 Subject: [PATCH 1/2] Partially completed task --- .ipynb_checkpoints/main-checkpoint.ipynb | 557 +++++++++++++++++++++++ main.ipynb | 266 +++++++++-- mod/__pycache__/testing.cpython-39.pyc | Bin 0 -> 13210 bytes 3 files changed, 776 insertions(+), 47 deletions(-) create mode 100644 .ipynb_checkpoints/main-checkpoint.ipynb create mode 100644 mod/__pycache__/testing.cpython-39.pyc diff --git a/.ipynb_checkpoints/main-checkpoint.ipynb b/.ipynb_checkpoints/main-checkpoint.ipynb new file mode 100644 index 0000000..da38107 --- /dev/null +++ b/.ipynb_checkpoints/main-checkpoint.ipynb @@ -0,0 +1,557 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Functions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "On this lab we will put to practice some of the concepts we have learned on this past few days.\n", + "\n", + "`NOTE: On this lab you should try to write all the functions yourself using only the most basic of python syntax and without functions such as len, count, sum, max, min, in, etc. Give it a try. 🧑ðŸŧ‍ðŸ’ŧðŸ‘ĐðŸŧ‍ðŸ’ŧ`\n", + "\n", + "The cell after each exercise contains a few tests to check if your function works as expected." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from mod.testing import *\n", + "import unittest" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1. Write a function that returns the greater of two numbers" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "def greater(a,b):\n", + " if a > b:\n", + " return a\n", + " elif b > a:\n", + " return b" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.072s\n", + "\n", + "OK\n" + ] + } + ], + "source": [ + "# This will test your function \n", + "test_greater(greater)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2. Now write a function that returns the largest element on a list" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "def greatest(arr):\n", + " greatest=0\n", + " for e in arr:\n", + " if e > greatest:\n", + " greatest=e\n", + " return greatest" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.067s\n", + "\n", + "OK\n" + ] + } + ], + "source": [ + "# This will test your function \n", + "test_greatest(greatest)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3. Write a function that sums all the elements on a list" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "def sum_all(arr):\n", + " sum_=0\n", + " for e in arr:\n", + " sum_+=e\n", + " return sum_" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.059s\n", + "\n", + "OK\n" + ] + } + ], + "source": [ + "# This will test your function \n", + "test_sum(sum_all)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4. Write another function that multiplies all the elements on a list" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "def mult_all(arr):\n", + " mult=1\n", + " for e in arr:\n", + " mult*=e\n", + " return mult" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.058s\n", + "\n", + "OK\n" + ] + } + ], + "source": [ + "# This will test your function \n", + "test_mult(mult_all)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 5. Now combine those two ideas and write a function that receives a list and either \"+\" or \"*\" and outputs acordingly" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "def oper_all(arr, oper):\n", + " if oper == \"+\":\n", + " sum_=0\n", + " for e in arr:\n", + " sum_+=e\n", + " return sum_\n", + " elif oper == \"*\":\n", + " mult=1\n", + " for e in arr:\n", + " mult*=e\n", + " return mult" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.056s\n", + "\n", + "OK\n" + ] + } + ], + "source": [ + "# This will test your function \n", + "test_operations(oper_all)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 6. Write a function that returns the factorial of a number." + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "def factorial(n):\n", + " fact = 1\n", + " while n > 0:\n", + " fact = fact*n\n", + " n-=1\n", + " return fact" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.076s\n", + "\n", + "OK\n" + ] + } + ], + "source": [ + "# This will test your function \n", + "test_factorial(factorial)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 7. Write a function that takes a list and returns a list of the unique values.\n", + "\n", + "`NOTE: You cannot use set. ðŸĪ”`" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "def unique(arr):\n", + " unique = []\n", + " for e in arr:\n", + " if e not in unique:\n", + " unique.append(e)\n", + " return unique" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.125s\n", + "\n", + "OK\n" + ] + } + ], + "source": [ + "# This will test your function \n", + "test_unique(unique)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 8. Write a function that returns the mode of a list, i.e.: the element that appears the most times.\n", + "`NOTE: You should not use count... 🧐`" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "a = [1,1,2,2,2,4,4,5,6]\n", + "def mode_counter(arr):\n", + " module=0\n", + " freq_module=0\n", + " freq_num={}\n", + " for e in arr:\n", + " freq_num[e]=0\n", + " for e in arr:\n", + " freq_num[e]+=1\n", + " for i,v in freq_num.items():\n", + " if v > freq_module:\n", + " freq_module = v\n", + " module = i\n", + " return module " + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.066s\n", + "\n", + "OK\n" + ] + } + ], + "source": [ + "# This will test your function \n", + "test_mode(mode_counter)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 9. Write a function that calculates the standard deviation of a list.\n", + "`NOTE: Do not use any libraries or already built functions. 😉`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "from statistics import stdev\n", + "def st_dev(arr):\n", + " elements = 0\n", + " total_sum = 0\n", + " sum_squares = 0\n", + " for e in arr:\n", + " elements +=1\n", + " total_sum = total_sum + e\n", + " mean = total_sum/elements\n", + " for e in arr:\n", + " to_sq = e - mean\n", + " sum_squares = sum_squares + (to_sq**2)\n", + " return (sum_squares/elements)**0.5" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# This will test your function \n", + "test_stdev(st_dev)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 10. Write a function to check if a string is a pangram, i.e.: if it contains all the letters of the alphabet at least once. Mind that the strings may contain characters that are not letters." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def pangram(string):\n", + " 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", + " for let in string:\n", + " for i, v in enumerate(alphabet):\n", + " if v == let.lower():\n", + " alphabet.pop(i)\n", + " if bool(alphabet):\n", + " return False\n", + " else:\n", + " return True" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# This will test your function \n", + "test_pangram(pangram)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 11. Write a function that receives a string of comma separated words and returns a string of comma separated words sorted alphabetically.\n", + "\n", + "`NOTE: You may use sorted but not split and definitely no join! ðŸĪŠ`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def sort_alpha(string):\n", + " word_list=[]\n", + " word=\"\"\n", + " for e in string:\n", + " if e ==\",\":\n", + " word_list.append(word)\n", + " word=\"\"\n", + " else:\n", + " word+=e\n", + " word_list.append(word)\n", + " word_list.sort()\n", + " word_string = \"\"\n", + " for e in word_list:\n", + " word_string+=e+\",\" \n", + " word_string = word_string[:-1]\n", + " return word_string" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# This will test your function \n", + "test_alpha(sort_alpha)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 12. Write a function to check if a given password is strong (at least 8 characters, at least one lower case, at least one upper case, at least one number and at least one special character). It should output True if strong and False if not.\n", + "`Valid special characters: # @ ! $ % & ( ) ^ * [ ] { }`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def check_pass(string):\n", + " pass" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# This will test your function \n", + "test_pass(check_pass)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.9.13" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/main.ipynb b/main.ipynb index 73f285a..da38107 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,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def greater(a,b):\n", - " pass" + " if a > b:\n", + " return a\n", + " elif b > a:\n", + " return b" ] }, { "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.072s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_greater(greater)" @@ -64,19 +79,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "def greatest(arr):\n", - " pass" + " greatest=0\n", + " for e in arr:\n", + " if e > greatest:\n", + " greatest=e\n", + " return greatest" ] }, { "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.067s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_greatest(greatest)" @@ -91,19 +122,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "def sum_all(arr):\n", - " pass" + " sum_=0\n", + " for e in arr:\n", + " sum_+=e\n", + " return sum_" ] }, { "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.059s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_sum(sum_all)" @@ -118,19 +164,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "def mult_all(arr):\n", - " pass" + " mult=1\n", + " for e in arr:\n", + " mult*=e\n", + " return mult" ] }, { "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.058s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_mult(mult_all)" @@ -145,19 +206,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "def oper_all(arr, oper):\n", - " pass" + " if oper == \"+\":\n", + " sum_=0\n", + " for e in arr:\n", + " sum_+=e\n", + " return sum_\n", + " elif oper == \"*\":\n", + " mult=1\n", + " for e in arr:\n", + " mult*=e\n", + " return mult" ] }, { "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.056s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_operations(oper_all)" @@ -172,19 +254,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "def factorial(n):\n", - " pass" + " fact = 1\n", + " while n > 0:\n", + " fact = fact*n\n", + " n-=1\n", + " return fact" ] }, { "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.076s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_factorial(factorial)" @@ -201,19 +299,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "def unique(arr):\n", - " pass" + " unique = []\n", + " for e in arr:\n", + " if e not in unique:\n", + " unique.append(e)\n", + " return unique" ] }, { "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.125s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_unique(unique)" @@ -229,19 +343,43 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, "outputs": [], "source": [ + "a = [1,1,2,2,2,4,4,5,6]\n", "def mode_counter(arr):\n", - " pass" + " module=0\n", + " freq_module=0\n", + " freq_num={}\n", + " for e in arr:\n", + " freq_num[e]=0\n", + " for e in arr:\n", + " freq_num[e]+=1\n", + " for i,v in freq_num.items():\n", + " if v > freq_module:\n", + " freq_module = v\n", + " module = i\n", + " return module " ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.066s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_mode(mode_counter)" @@ -258,12 +396,24 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "from statistics import stdev\n", "def st_dev(arr):\n", - " pass" + " elements = 0\n", + " total_sum = 0\n", + " sum_squares = 0\n", + " for e in arr:\n", + " elements +=1\n", + " total_sum = total_sum + e\n", + " mean = total_sum/elements\n", + " for e in arr:\n", + " to_sq = e - mean\n", + " sum_squares = sum_squares + (to_sq**2)\n", + " return (sum_squares/elements)**0.5" ] }, { @@ -290,7 +440,15 @@ "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", + " for let in string:\n", + " for i, v in enumerate(alphabet):\n", + " if v == let.lower():\n", + " alphabet.pop(i)\n", + " if bool(alphabet):\n", + " return False\n", + " else:\n", + " return True" ] }, { @@ -319,7 +477,21 @@ "outputs": [], "source": [ "def sort_alpha(string):\n", - " pass" + " word_list=[]\n", + " word=\"\"\n", + " for e in string:\n", + " if e ==\",\":\n", + " word_list.append(word)\n", + " word=\"\"\n", + " else:\n", + " word+=e\n", + " word_list.append(word)\n", + " word_list.sort()\n", + " word_string = \"\"\n", + " for e in word_list:\n", + " word_string+=e+\",\" \n", + " word_string = word_string[:-1]\n", + " return word_string" ] }, { @@ -363,7 +535,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -377,7 +549,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.6" + "version": "3.9.13" } }, "nbformat": 4, diff --git a/mod/__pycache__/testing.cpython-39.pyc b/mod/__pycache__/testing.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c988db65ee1c5d402c293420c307da4fff2d1115 GIT binary patch literal 13210 zcmds8OKcoT8Sd(ymmSA;9vf$~*=#3q9+Nn;%MxB8ggo{U0$96ivw_)UXWLUfcW=Lj-@pHMCBI^7+TZD-{ioyNDh~g*D7eO%t7X-hWf`t@S1%b^ zgV8<1jg{irxU9$AL@Aj~mQvZ2ypFqlrT%PxX-{@fX&^g*dkLO=pk?>+6z{`%koWUF zI1ljwz8B|VKFEh~-p7aeKAiXS{rmvV2lzq$49*AnAwGihGewOb{t3$-;?MFUxE|rp z@uN5&=FjtEI6uqTgqD6`9o%c>FD>aoY$eWPJigji)3qgIDYnQ~67Oq^#$v3f2T65a zX3P32W7@s5pp{zHR{9nhU2_e+O^oN!c*l=eqMv^bg{{%hW%Y;bq1Iq7Ydq8oj2k@m zAeD_h)M8pT4pQ;j3xVwixuUSGz!sUyu9vr5|4L>OcfVTp=F0g7X(CT`Iu79QkD&-O zaIP)uD{NI`+9F%ja{8i<(jZRP*!Wruvadp_VJeq%%1)5Wg>k1`sRm)fs|Gl)8DY$~ z-GbN)dSVd8njZEw+YkG4xx8!nelEABJ-T?~(w%Skw(##vOnD->;|Q-jZRKb0xYpE# zLbaR^9Ix!(!7$&UemUi0rm`RgKy(idKY>DHgDk;nXSeBhronE<6rkxqM5F*tpt7i~ zND<7i4^f}NRG{*Q+K=^B2^t7NAAi(8G3`}dZcf=Iy1NIxu|@Fey{hH5^_q!c5L{!S zUMP!$sETJ$gh^2?lQig|PjJ;(?aX$}*S}dykl4#s$%febb2-SR>Qa3mm!sCz6Dc3@ zJTVoewO@kks+vBm`TTrwu_l5+85C{k=NF7K>!T&*Ae&*R7I|G-pP z>km^^3_CF#rl=n`2yb$HC#p_hhjC$*i#C93mAO|!cX4*gL722Sr}smnWX*?zllFW- zmv2?eWy~f6Jxs?XQ#8Sd5X*(k3fYvB-N^=@;Q+PWnBjfIFwF;z9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yM8_rQO-s=uJc#KjNGgfde@FQ54eHIZDP3 z#l1m>En-c)N(8joSlwh|LhftOL&LSp(kMVG@{9O7WO-~hPGGHvZ=j$r&CUiBxh@Cwbaq0!IM{ykDfYxHvR6ockX_BX+1@xZlgc~@;cS23xYr<Mhf=)&E{b;a}+kIRp)Vp&iRDfwwDtnj!1M^x>9@xkXx8HQiEe zTC}G?DxK^yHrq_hX2icextvYrr|tY~t|B;bVpGwjm{nwwn*9TwwxyPpW=3qXN-ZBz zEtBZ*?;Nzd-}78wrql7S9B|QP@-OW71MDZkZvVWm!ZM`A1to2|=NfIrk$Y0b4XWLw zVw?)f_R0K%42lX0%!v1>C{RJmgycx|Lv}_Ma+OJ4R@>^Y5Y8knQ&?RF@Hfm38mS@t O4dd7^OLaAv8u~Bou6h^% literal 0 HcmV?d00001 From ccc7c68d915b766fed9d003a1b1880f8368cb37b Mon Sep 17 00:00:00 2001 From: sborto86 Date: Thu, 6 Oct 2022 20:00:14 +0200 Subject: [PATCH 2/2] Completed Task --- .ipynb_checkpoints/main-checkpoint.ipynb | 50 +++++++++++++++++++++--- main.ipynb | 50 +++++++++++++++++++++--- 2 files changed, 90 insertions(+), 10 deletions(-) diff --git a/.ipynb_checkpoints/main-checkpoint.ipynb b/.ipynb_checkpoints/main-checkpoint.ipynb index da38107..9593c7d 100644 --- a/.ipynb_checkpoints/main-checkpoint.ipynb +++ b/.ipynb_checkpoints/main-checkpoint.ipynb @@ -395,7 +395,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": { "scrolled": true }, @@ -514,23 +514,63 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "def check_pass(string):\n", - " pass" + " upper=False\n", + " number=False\n", + " special=False\n", + " lenght=False\n", + " strong=False\n", + " s_lenght=0\n", + " numbers_list=[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"0\"]\n", + " special_list=[\"#\", \"@\", \"!\", \"$\", \"%\", \"&\", \"(\", \")\", \"^\", \"*\", \"[\", \"]\", \"{\", \"}\"]\n", + " upper_list=['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", + " for ch in string:\n", + " s_lenght+=1\n", + " if ch in numbers_list:\n", + " number=True\n", + " elif ch in special_list:\n", + " special=True\n", + " elif ch in upper_list:\n", + " upper=True\n", + " if s_lenght >=8:\n", + " lenght=True\n", + " if upper and number and special and lenght == True:\n", + " strong = True\n", + " return strong" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.166s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_pass(check_pass)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/main.ipynb b/main.ipynb index da38107..9593c7d 100644 --- a/main.ipynb +++ b/main.ipynb @@ -395,7 +395,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": { "scrolled": true }, @@ -514,23 +514,63 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "def check_pass(string):\n", - " pass" + " upper=False\n", + " number=False\n", + " special=False\n", + " lenght=False\n", + " strong=False\n", + " s_lenght=0\n", + " numbers_list=[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"0\"]\n", + " special_list=[\"#\", \"@\", \"!\", \"$\", \"%\", \"&\", \"(\", \")\", \"^\", \"*\", \"[\", \"]\", \"{\", \"}\"]\n", + " upper_list=['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", + " for ch in string:\n", + " s_lenght+=1\n", + " if ch in numbers_list:\n", + " number=True\n", + " elif ch in special_list:\n", + " special=True\n", + " elif ch in upper_list:\n", + " upper=True\n", + " if s_lenght >=8:\n", + " lenght=True\n", + " if upper and number and special and lenght == True:\n", + " strong = True\n", + " return strong" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.166s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_pass(check_pass)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {