Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 135 additions & 36 deletions Game.ipynb → .ipynb_checkpoints/Game-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# Exercise 1: Can YOU call Mr. OS?\n",
"# Hint: import os\n"
"# Hint: import os\n",
"import os "
]
},
{
Expand All @@ -48,9 +49,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"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",
Expand All @@ -77,13 +87,16 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# Exercise 2: Can YOU tell Mr. OS to create the directories \n",
"# \"cybergear\", \"cyberpack\", and \"cyberweapons\"?\n",
"# Hint: os.mkdir(<name-of-directory>)\n"
"# Hint: os.mkdir(<name-of-directory>)\n",
"os.mkdir(\"cybergear\")\n",
"os.mkdir(\"cyberpack\")\n",
"os.mkdir(\"cyberweapons\")"
]
},
{
Expand All @@ -95,9 +108,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"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",
Expand Down Expand Up @@ -126,9 +147,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[]\n"
]
}
],
"source": [
"# Run the following command to see all your items in cyberpack\n",
"items_in_cyberweapons = os.listdir(\"cyberweapons\")\n",
Expand All @@ -144,12 +173,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"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\")"
]
},
{
Expand All @@ -161,9 +202,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"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",
Expand All @@ -189,13 +239,16 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# Exercise 4: Write \"YOU HAVE BEEN INFECTED\" into the file contents \n",
"# of cyberweapons/Virus\n",
"# hint: open(<name-of-file>, <permissions>) and using the file write command\n"
"# hint: open(<name-of-file>, <permissions>) and using the file write command\n",
"file = open(\"cyberweapons/Virus.txt\", \"w\")\n",
"file.write(\"YOU HAVE BEEN INFECTED\")\n",
"file.close()"
]
},
{
Expand All @@ -207,9 +260,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"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",
Expand All @@ -230,7 +291,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -248,12 +309,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "AttributeError",
"evalue": "module 'os' has no attribute 'listdirs'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-15-f130d751e6c6>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mitem\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mcybergear_contents\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msystem\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"touch cybergear/\"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mitem\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlistdirs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"cybergear\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m'cyberutilitybelt'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'cyberrouter'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'cyberwatch'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'cyberswitch'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'cyberflashlight'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'cybercable'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAttributeError\u001b[0m: module 'os' has no attribute 'listdirs'"
]
}
],
"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",
"print(os.listdirs(\"cybergear\"))\n",
"['cyberutilitybelt', 'cyberrouter', 'cyberwatch', 'cyberswitch', 'cyberflashlight', 'cybercable']"
]
},
{
Expand All @@ -267,7 +344,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 16,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -300,7 +377,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -321,13 +398,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['taco', 'quesadilla', 'burrito', 'chicharron', 'pupusa']\n"
]
}
],
"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)\n",
"print(os.listdir(\"cyberpack\"))"
]
},
{
Expand All @@ -339,7 +427,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 19,
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -380,7 +468,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -401,12 +489,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"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']"
]
},
{
Expand All @@ -418,9 +507,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "SyntaxError",
"evalue": "invalid syntax (<ipython-input-22-c998791c2b55>, line 2)",
"output_type": "error",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-22-c998791c2b55>\"\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",
Expand Down Expand Up @@ -452,7 +550,8 @@
"metadata": {},
"outputs": [],
"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"
]
}
],
Expand All @@ -472,7 +571,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.7.6"
}
},
"nbformat": 4,
Expand Down
Empty file added Anaconda.sh
Empty file.
2 changes: 1 addition & 1 deletion run.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
jupyter-notebook --ip=0.0.0.0
jupyter-notebook --ip=0.0.0.0 --allow-root
Loading