diff --git a/.gitignore.txt b/.gitignore.txt new file mode 100644 index 0000000..b6085cb --- /dev/null +++ b/.gitignore.txt @@ -0,0 +1,2 @@ +.ipynb_checkpoints/ +mod/__pycache__/ diff --git a/main.ipynb b/main.ipynb index 73f285a..964446c 100644 --- a/main.ipynb +++ b/main.ipynb @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "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.055s\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" + " largest = 0\n", + " for element in arr:\n", + " if element > largest:\n", + " largest = element\n", + " return largest" ] }, { "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.056s\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 num in arr:\n", + " sum_ += num\n", + " return sum_" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.062s\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": 32, "metadata": {}, "outputs": [], "source": [ "def mult_all(arr):\n", - " pass" + " mult = 1\n", + " for num in arr:\n", + " mult *= num\n", + " return mult" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.057s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_mult(mult_all)" @@ -145,19 +206,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "metadata": {}, "outputs": [], "source": [ "def oper_all(arr, oper):\n", - " pass" + " if oper == '+':\n", + " return sum_all(arr)\n", + " elif oper == '*':\n", + " return mult_all(arr)" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 35, + "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_operations(oper_all)" @@ -172,19 +248,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": {}, "outputs": [], "source": [ "def factorial(n):\n", - " pass" + " fact = 1\n", + " for num in range(1,n+1):\n", + " fact *= num\n", + " return fact" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.069s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_factorial(factorial)" @@ -201,19 +292,36 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 49, "metadata": {}, "outputs": [], "source": [ "def unique(arr):\n", - " pass" + " list_unique = []\n", + " for element in arr:\n", + " if element not in list_unique:\n", + " list_unique.append(element)\n", + " return list_unique\n", + " " ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.119s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_unique(unique)" @@ -229,19 +337,43 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 81, "metadata": {}, "outputs": [], "source": [ "def mode_counter(arr):\n", - " pass" + " count = 0\n", + " max_count = 0\n", + " mode = 0\n", + " for element in arr:\n", + " for i in arr:\n", + " if i == element:\n", + " count +=1\n", + " if count > max_count:\n", + " max_count = count\n", + " mode = element\n", + " count = 0\n", + " return mode\n", + " " ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 82, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.124s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_mode(mode_counter)" @@ -257,20 +389,49 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 77, "metadata": {}, "outputs": [], "source": [ "from statistics import stdev\n", "def st_dev(arr):\n", - " pass" + " \n", + " total_elements = 0\n", + " total_sum_elements = 0\n", + " \n", + " for num in arr:\n", + " total_elements +=1\n", + " total_sum_elements += num\n", + " \n", + " mean = total_sum_elements/total_elements\n", + " \n", + " deviation = 0\n", + " \n", + " for num in arr:\n", + " deviation += (num-mean)**2\n", + " \n", + " standard_deviation = (deviation/(total_elements-1))**0.5\n", + " \n", + " return standard_deviation" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 78, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.063s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_stdev(st_dev)" @@ -285,19 +446,39 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 73, "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", + " is_pangram = True\n", + " \n", + " for letter in alphabet:\n", + " if letter not in string.lower():\n", + " is_pangram = False\n", + " \n", + " return is_pangram\n", + " " ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 74, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "..............................\n", + "----------------------------------------------------------------------\n", + "Ran 30 tests in 0.020s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_pangram(pangram)" @@ -314,19 +495,52 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "def sort_alpha(string):\n", - " pass" + " separated_words = []\n", + " string_aux = ''\n", + " \n", + " for character in string:\n", + " if character == ',':\n", + " separated_words.append(string_aux)\n", + " string_aux = ''\n", + " \n", + " else:\n", + " string_aux += character\n", + " \n", + " separated_words.append(string_aux) \n", + " \n", + " sorted_words = sorted(separated_words)\n", + " \n", + " sorted_string = ''\n", + " \n", + " for element in sorted_words:\n", + " sorted_string += element + ','\n", + " \n", + " return sorted_string[:-1]\n", + " " ] }, { "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.071s\n", + "\n", + "OK\n" + ] + } + ], "source": [ "# This will test your function \n", "test_alpha(sort_alpha)" @@ -342,28 +556,76 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 101, "metadata": {}, "outputs": [], "source": [ "def check_pass(string):\n", - " pass" + " total_characters = 0\n", + " lowercase_count = 0\n", + " upperrcase_count = 0\n", + " number_count = 0\n", + " special_char_count = 0\n", + " \n", + " lowercase_letters = ['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", + " uppercase_letters = ['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", + " numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']\n", + " special_characters = ['#', '@', '!', '$', '%', '&', '(', ')', '^', '*', '[', ']', '{', '}']\n", + " \n", + " for character in string:\n", + " total_characters += 1\n", + " \n", + " if character in lowercase_letters:\n", + " lowercase_count += 1\n", + " \n", + " elif character in uppercase_letters:\n", + " upperrcase_count += 1\n", + " \n", + " elif character in numbers:\n", + " number_count += 1\n", + " \n", + " elif character in special_characters:\n", + " special_char_count += 1\n", + " \n", + " else:\n", + " return False\n", + " \n", + " return total_characters >= 8 and lowercase_count >=1 and upperrcase_count >=1 and number_count >=1 and special_char_count >=1" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 102, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "----------------------------------------------------------------------\n", + "Ran 100 tests in 0.032s\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": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -377,7 +639,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.6" + "version": "3.9.12" } }, "nbformat": 4,