diff --git a/notebooks/beginner/exercises/conditionals_exercise.ipynb b/notebooks/beginner/exercises/conditionals_exercise.ipynb index e0e045c..3c981f0 100644 --- a/notebooks/beginner/exercises/conditionals_exercise.ipynb +++ b/notebooks/beginner/exercises/conditionals_exercise.ipynb @@ -10,7 +10,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "editable": false }, @@ -21,20 +21,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Name \"John Doe\" is 8, 9 or 10 chars long\n" + ] + } + ], "source": [ - "if ____:\n", + "if len(name)>20:\n", " print('Name \"{}\" is more than 20 chars long'.format(name))\n", " length_description = 'long'\n", - "elif ____:\n", + "elif len(name)>15:\n", " print('Name \"{}\" is more than 15 chars long'.format(name))\n", " length_description = 'semi long'\n", - "elif ____:\n", + "elif len(name)>10:\n", " print('Name \"{}\" is more than 10 chars long'.format(name))\n", " length_description = 'semi long'\n", - "elif ____:\n", + "elif len(name)>7:\n", " print('Name \"{}\" is 8, 9 or 10 chars long'.format(name))\n", " length_description = 'semi short'\n", "else:\n", @@ -44,7 +52,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "editable": false }, @@ -52,11 +60,18 @@ "source": [ "assert length_description == 'semi short'" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -70,7 +85,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.4" + "version": "3.8.12" } }, "nbformat": 4, diff --git a/notebooks/beginner/exercises/for_loops_exercise.ipynb b/notebooks/beginner/exercises/for_loops_exercise.ipynb index eae36c6..f94b1cb 100644 --- a/notebooks/beginner/exercises/for_loops_exercise.ipynb +++ b/notebooks/beginner/exercises/for_loops_exercise.ipynb @@ -10,21 +10,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "words = ['PYTHON', 'JOHN', 'chEEse', 'hAm', 'DOE', '123']\n", "upper_case_words = []\n", "\n", - "for ____ in words:\n", - " if ____.isupper():\n", - " ____.append(____)" + "for word in words:\n", + " if word.isupper():\n", + " upper_case_words.append(word)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "editable": false }, @@ -43,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "editable": false }, @@ -54,17 +54,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "# Your implementation\n", - "sum_of_values = " + "sum_of_values = sum(x for x in magic_dict.values() if isinstance(x, (int, float)))" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": { "editable": false }, @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": { "editable": false }, @@ -98,17 +98,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "# Your implementation\n", - "my_list = " + "my_list = []\n", + "\n", + "for num in numbers:\n", + " if num%5==0 and num%2!=0:\n", + " my_list.append(\"five odd\")\n", + " elif num%5==0 and num%2==0:\n", + " my_list.append(\"five even\")\n", + " elif num%2==0:\n", + " my_list.append('even')\n", + " else:\n", + " my_list.append('odd')\n", + " " ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": { "editable": false }, @@ -116,11 +127,18 @@ "source": [ "assert my_list == ['odd', 'odd', 'even', 'even', 'odd', 'five even', 'five even', 'five odd']" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -134,7 +152,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.4" + "version": "3.8.12" } }, "nbformat": 4, diff --git a/notebooks/beginner/exercises/strings_exercise.ipynb b/notebooks/beginner/exercises/strings_exercise.ipynb index 38aee8b..6b42c4d 100644 --- a/notebooks/beginner/exercises/strings_exercise.ipynb +++ b/notebooks/beginner/exercises/strings_exercise.ipynb @@ -10,14 +10,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "original = ' Python strings are COOL! '\n", - "lower_cased = original._____\n", - "stripped = ____.strip()\n", - "stripped_lower_cased = original._____._____" + "lower_cased = original.lower()\n", + "stripped = original.strip()\n", + "stripped_lower_cased = original.lower().strip()" ] }, { @@ -29,7 +29,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "editable": false }, @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": { "editable": false }, @@ -61,12 +61,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'Title Of My New Book'" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Your implementation:\n", - "pretty = 'TODO'" + "pretty = ugly.strip().title()\n", + "pretty" ] }, { @@ -78,11 +90,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": { "editable": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "pretty: Title Of My New Book\n" + ] + } + ], "source": [ "print('pretty: {}'.format(pretty))\n", "assert pretty == 'Title Of My New Book'" @@ -98,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": { "editable": false }, @@ -111,30 +131,57 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'Learning Python is fun!'" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Your implementation:\n", - "sentence = 'TODO'" + "sentence = \"Learning \" + language + ' ' + verb + ' ' + \"fun\" + punctuation\n", + "sentence" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": { "editable": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "sentence: Learning Python is fun!\n" + ] + } + ], "source": [ "print('sentence: {}'.format(sentence))\n", "assert sentence == 'Learning Python is fun!'" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -148,7 +195,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.4" + "version": "3.8.12" } }, "nbformat": 4,