From 0dfe18ed5d6e753689f28881696e6dd90f0b5ab1 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 5 Apr 2020 18:34:21 -0400 Subject: [PATCH] answers --- .ipynb_checkpoints/Game-checkpoint.ipynb | 480 +++++++++++++++++++++++ Game.ipynb | 195 +++++++-- run.sh | 2 +- 3 files changed, 635 insertions(+), 42 deletions(-) create mode 100644 .ipynb_checkpoints/Game-checkpoint.ipynb mode change 100644 => 100755 run.sh diff --git a/.ipynb_checkpoints/Game-checkpoint.ipynb b/.ipynb_checkpoints/Game-checkpoint.ipynb new file mode 100644 index 0000000..0eb073b --- /dev/null +++ b/.ipynb_checkpoints/Game-checkpoint.ipynb @@ -0,0 +1,480 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Dora the Explorer" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Title](img/dora.jpg)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Hola, amigos! My name is Dora the Explorer! Today, we are visiting Cyberville! It's a wonderful place where we get to learn about python, data structures, loops, and more! \n", + "\n", + "Please join me on my adventure! First, I'm going to need a friend to help me on my journey! I need the help from the fantastic Python module Mr. OS! \n", + "\n", + "I'm going to need your help! How do I call Mr. OS to call him? Someone is going to have to import him into Cyberville!\n", + "\n", + "In the next cell, please import him!" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "# Exercise 1: Can YOU call Mr. OS?\n", + "# Hint: import os\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If you feel like you have written the code above called him successfully, let's run the next line of code just to make sure!\n", + "\n", + "Hi, Mr. OS! It's me! Dora!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Run this to test your code in Exercise 1\n", + "try:\n", + " print(os.popen(\"echo 'Why hullo there, Dora!'\").read())\n", + "except:\n", + " raise Exception(\"He's not here yet! Go back and import him! Remember the 'import' command!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Title](img/mros.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Backpack is getting so tired from carrying too much stuff! Please tell Mr. OS to create three new directories to help me!\n", + "\n", + "Please store them in the same directory as our project. I would like my new directories to be named, \"cybergear\", \"cyberpack\", and \"cyberweapons\"!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Exercise 2: Can YOU tell Mr. OS to create the directories \n", + "# \"cybergear\", \"cyberpack\", and \"cyberweapons\"?\n", + "# Hint: os.mkdir()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If you think Mr. OS has successfully created them, run the following code so we can see if we can talk to our new friends!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Run this code to test that you have created the three files from the\n", + "# exercise above\n", + "cybergear_is_directory = os.path.isdir(\"cybergear\")\n", + "cyberpack_is_directory = os.path.isdir(\"cyberpack\")\n", + "cyberweapons_is_directory = os.path.isdir(\"cyberweapons\")\n", + "if (cybergear_is_directory and cyberpack_is_directory and cyberweapons_is_directory):\n", + " print(\"Maravilloso! Welcome, my new friends!\")\n", + "else:\n", + " raise Exception(\"I don't see our new friends anywhere!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Title](img/cyberdirs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Alright! We are going out on an adventure now! Before you run into danger too quickly, remember! When you want to see all your items in any of our friends, \"cyberpack\", \"cybergear\", or \"cyberweapons\", run the listdir command on them to see." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Run the following command to see all your items in cyberpack\n", + "items_in_cyberweapons = os.listdir(\"cyberweapons\")\n", + "print(items_in_cyberweapons)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Aww... It looks like cyberpack is empty right now. How about we populate her with some lethal weapons? Use os.system() and the touch command in bash to create a file named \"Virus.txt\". " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Exercise 3: Can YOU create some files in the cyberweapons directory?\n", + "# hint: Use the os.system() command\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Once you are finished writing and executing the code, let's test it out if it was successful below:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Run this to test your code in Exercise 3\n", + "items_in_cyberweapons = os.listdir(\"cyberweapons\")\n", + "if \"Virus.txt\" in items_in_cyberweapons:\n", + " print(\"Yay! We have a Virus.txt weapon!\")\n", + "elif len(items_in_cyberweapons) == 0:\n", + " raise Exception(\"The directory cyberweapons is still empty!\")\n", + "else:\n", + " raise Exception(\"I'm glad we have weapons, but we need a weapon named Virus for this to work!\")\n", + "print(items_in_cyberweapons)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's write some stuff in the Virus.txt file. Let's have it contain the following contents:\n", + "\n", + "YOU HAVE BEEN INFECTED\n", + "\n", + "Could you please open the file and write the contents to it?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Exercise 4: Write \"YOU HAVE BEEN INFECTED\" into the file contents \n", + "# of cyberweapons/Virus\n", + "# hint: open(, ) and using the file write command\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If you are finished writing and running the code, check your work by running the following code below:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Test to see if the above coding snippet has run successfully\n", + "fn = \"cyberweapons/Virus.txt\"\n", + "file = open(fn, 'r')\n", + "virus_contents = file.read()\n", + "if virus_contents == \"YOU HAVE BEEN INFECTED\":\n", + " print(\"This looks great!\")\n", + "else:\n", + " raise Exception(\"Please go back, and make sure everything is spelled right!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "After you have populated the Virus.txt file correctly, please run the following snippet of code. It will give you a list of things that we need in the cybergear directory. " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Run the following code to initialize cybergear contents\n", + "cybergear_contents = [\"cyberwatch\", \"cyberflashlight\", \"cyberswitch\", \n", + " \"cyberrouter\", \"cybercable\", \"cyberutilitybelt\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Using a for loop, use the list above to create files of the same names in the cybergear directory. Use any method that you would like." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Exercise 5: for each item in cybergear_contents, \n", + "# create files of the same name in the cybergear directory\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Once you are finished writing and executing the code above, let's see if the cybergear directory has all of the new items in her.\n", + "\n", + "Alright, cybergear! List your contents!" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Great! It looks like cybergear has the right contents!\n" + ] + } + ], + "source": [ + "# Run this code to test that you have successfully added the list to\n", + "# the cybergear directory\n", + "import os\n", + "cybergear_files = os.listdir(\"cybergear\")\n", + "for item in cybergear_contents:\n", + " if item not in cybergear_files:\n", + " raise Exception(\"It looks like there are still some items missing, amigo!\")\n", + "print(\"Great! It looks like cybergear has the right contents!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Miren, amigos! We have made it to the Magical Hex Lake! Many fishermen of Cyberville regularly come here to catch tilapia!\n", + "\n", + "Wow! Next to the lake is a treasure chest! Let's take a look at the contents inside of the treasure chest!" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "# Run this code to initialize the treasure chest\n", + "treasure_chest_contents = [\"taco\", \"quesadilla\", \"burrito\", \n", + " \"chicharron\", \"pupusa\", \"arroz con leche\",\n", + " \"flan\", \"salteƱa\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Oh, no! It seems there are so many items to choose from! I only have room to carry a subset of the things I found in the treasure chest! Please use a for loop to put five items in the treasure chest contents into the directory cyberpack!\n", + "\n", + "Use the next cell to put your code!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Exercise 6: Can YOU put only five items from treasure_chest_contents \n", + "# into the cyberpack directory?\n", + "# hint: This will require the use of the for loop and touch command\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Once you are finished writing and running the code, let's check to see if you have successfully added the items!" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "We did it! We did it! Yay! Lo hicimos!\n" + ] + } + ], + "source": [ + "# Run this code to test if you successfully completed Exercise 6!\n", + "i = 0\n", + "cyberpack_contents = os.listdir(\"cyberpack\")\n", + "for item in cyberpack_contents:\n", + " if item in treasure_chest_contents:\n", + " i += 1\n", + "if i >= 5:\n", + " print(\"We did it! We did it! Yay! Lo hicimos!\")\n", + "else:\n", + " raise Exception(\"Please add five items from the treasure chest into the cyberpack directory.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Oh, no. It looks like Swiper is at it again! He stole the cyberweapons directory! \n", + "\n", + "![Title](img/swiper.png)\n", + "\n", + "Wait! We still have a chance to stop him! We have a dictionary of codes we can use to deploy Virus.txt which is in the cyberweapons bag.\n", + "\n", + "Here are the list of items in the dictionary." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Run this code to activate\n", + "dictionary_of_codes = {\n", + " \"foodcode\" : \"Zm9vZGNvZGU=\",\n", + " \"viruscode\" : \"dmlydXNjb2Rl\",\n", + " \"musiccode\" : \"bXVzaWNjb2Rl\"\n", + "}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create a new variable called activation_code and set it to the value stored under \"viruscode\" in the dictionary_of_codes." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Exercise 7: Store the value in \"viruscode\" in the variable \"activation_code\"\n", + "# hint: value_of_attribute = dictionary[\"attribute\"]\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now hurry! Run the code below to use the activation_code!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Activate the Virus.txt!\n", + "if activation_code == \"dmlydXNjb2Rl\"\n", + " print(\"SWIPER NO SWIPING!\")\n", + " print(os.popen(\"cat cyberweapons/Virus.txt\").read())\n", + "else:\n", + " raise Exception(\"Hurry! Swiper is getting away!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![title](img/awman.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Yay! It looks like we saved the day! It looks like we did enough exploring for now! Let's say goodbye to our friends now that we are finished with the day. \n", + "\n", + "Goodbye, Mr. OS! Goodbye, cyberweapons, cybergear, and cyberpack! Thank you all for your help!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Exercise 8: Remove all cyber directories using the os.system() command\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.5" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/Game.ipynb b/Game.ipynb index ef08be6..e63a913 100644 --- a/Game.ipynb +++ b/Game.ipynb @@ -29,12 +29,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "# Exercise 1: Can YOU call Mr. OS?\n", - "# Hint: import os\n" + "# Hint: import os\n", + "import os" ] }, { @@ -48,9 +49,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Why hullo there, Dora!\n", + "\n" + ] + } + ], "source": [ "# Run this to test your code in Exercise 1\n", "try:\n", @@ -77,13 +87,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "OSError", + "evalue": "[Errno 17] File exists: 'cybergear'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mOSError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;31m# \"cybergear\", \"cyberpack\", and \"cyberweapons\"?\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m# Hint: os.mkdir()\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmkdir\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"cybergear\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmkdir\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"cyberpack\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmkdir\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"cyberweapons\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mOSError\u001b[0m: [Errno 17] File exists: 'cybergear'" + ] + } + ], "source": [ "# Exercise 2: Can YOU tell Mr. OS to create the directories \n", "# \"cybergear\", \"cyberpack\", and \"cyberweapons\"?\n", - "# Hint: os.mkdir()\n" + "# Hint: os.mkdir()\n", + "os.mkdir(\"cybergear\")\n", + "os.mkdir(\"cyberpack\")\n", + "os.mkdir(\"cyberweapons\")" ] }, { @@ -95,9 +120,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Maravilloso! Welcome, my new friends!\n" + ] + } + ], "source": [ "# Run this code to test that you have created the three files from the\n", "# exercise above\n", @@ -126,9 +159,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'os' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# Run the following command to see all your items in cyberpack\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mitems_in_cyberweapons\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlistdir\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"cyberweapons\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mitems_in_cyberweapons\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mNameError\u001b[0m: name 'os' is not defined" + ] + } + ], "source": [ "# Run the following command to see all your items in cyberpack\n", "items_in_cyberweapons = os.listdir(\"cyberweapons\")\n", @@ -144,12 +189,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'os' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# Exercise 3: Can YOU create some files in the cyberweapons directory?\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;31m# hint: Use the os.system() command\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msystem\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"touch cyberweapons/Virus.txt\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mNameError\u001b[0m: name 'os' is not defined" + ] + } + ], "source": [ "# Exercise 3: Can YOU create some files in the cyberweapons directory?\n", - "# hint: Use the os.system() command\n" + "# hint: Use the os.system() command\n", + "os.system(\"touch cyberweapons/Virus.txt\")" ] }, { @@ -161,9 +219,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Yay! We have a Virus.txt weapon!\n", + "['Virus.txt']\n" + ] + } + ], "source": [ "# Run this to test your code in Exercise 3\n", "items_in_cyberweapons = os.listdir(\"cyberweapons\")\n", @@ -189,13 +256,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "# Exercise 4: Write \"YOU HAVE BEEN INFECTED\" into the file contents \n", "# of cyberweapons/Virus\n", - "# hint: open(, ) and using the file write command\n" + "# hint: open(, ) and using the file write command\n", + "fn = \"cyberweapons/Virus.txt\"\n", + "file = open(fn,\"w\")\n", + "file.write(\"YOU HAVE BEEN INFECTED\")\n", + "file.close()" ] }, { @@ -207,9 +278,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "This looks great!\n" + ] + } + ], "source": [ "# Test to see if the above coding snippet has run successfully\n", "fn = \"cyberweapons/Virus.txt\"\n", @@ -230,7 +309,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -248,12 +327,15 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "# Exercise 5: for each item in cybergear_contents, \n", - "# create files of the same name in the cybergear directory\n" + "# create files of the same name in the cybergear directory\n", + "for item in cybergear_contents:\n", + " os.system(\"touch cybergear/\" + item)\n", + " " ] }, { @@ -267,7 +349,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -300,7 +382,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -321,13 +403,15 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "# Exercise 6: Can YOU put only five items from treasure_chest_contents \n", "# into the cyberpack directory?\n", - "# hint: This will require the use of the for loop and touch command\n" + "# hint: This will require the use of the for loop and touch command\n", + "for item in treasure_chest_contents[0:5]:\n", + " os.system(\"touch cyberpack/\" + item)" ] }, { @@ -339,7 +423,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 14, "metadata": { "scrolled": true }, @@ -380,7 +464,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -401,12 +485,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "# Exercise 7: Store the value in \"viruscode\" in the variable \"activation_code\"\n", - "# hint: value_of_attribute = dictionary[\"attribute\"]\n" + "# hint: value_of_attribute = dictionary[\"attribute\"]\n", + "activation_code = dictionary_of_codes['viruscode']\n" ] }, { @@ -418,9 +503,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 2)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m if activation_code == \"dmlydXNjb2Rl\"\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" + ] + } + ], "source": [ "# Activate the Virus.txt!\n", "if activation_code == \"dmlydXNjb2Rl\"\n", @@ -448,31 +542,50 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Exercise 8: Remove all cyber directories using the os.system() command\n" + "# Exercise 8: Remove all cyber directories using the os.system() command\n", + "os.system(\"rm -rf cyber*\")\n" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 2", "language": "python", - "name": "python3" + "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 3 + "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.4" + "pygments_lexer": "ipython2", + "version": "2.7.5" } }, "nbformat": 4, diff --git a/run.sh b/run.sh old mode 100644 new mode 100755 index d19fd10..221413a --- a/run.sh +++ b/run.sh @@ -1,2 +1,2 @@ #!/bin/bash -jupyter-notebook --ip=0.0.0.0 +jupyter-notebook --ip=0.0.0.0 --allow-root