Skip to content

Commit 0f14403

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 8af57b8 + b027a15 commit 0f14403

17 files changed

+4817
-671
lines changed

00-Python Object and Data Structure Basics/08-Sets and Booleans.ipynb 00-Python Object and Data Structure Basics/.ipynb_checkpoints/07-Sets and Booleans-checkpoint.ipynb

+22-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
{
1717
"cell_type": "code",
1818
"execution_count": 1,
19-
"metadata": {},
19+
"metadata": {
20+
"collapsed": true
21+
},
2022
"outputs": [],
2123
"source": [
2224
"x = set()"
@@ -25,7 +27,9 @@
2527
{
2628
"cell_type": "code",
2729
"execution_count": 2,
28-
"metadata": {},
30+
"metadata": {
31+
"collapsed": true
32+
},
2933
"outputs": [],
3034
"source": [
3135
"# We add to sets with the add() method\n",
@@ -65,7 +69,9 @@
6569
{
6670
"cell_type": "code",
6771
"execution_count": 4,
68-
"metadata": {},
72+
"metadata": {
73+
"collapsed": true
74+
},
6975
"outputs": [],
7076
"source": [
7177
"# Add a different element\n",
@@ -96,7 +102,9 @@
96102
{
97103
"cell_type": "code",
98104
"execution_count": 6,
99-
"metadata": {},
105+
"metadata": {
106+
"collapsed": true
107+
},
100108
"outputs": [],
101109
"source": [
102110
"# Try to add the same element\n",
@@ -134,7 +142,9 @@
134142
{
135143
"cell_type": "code",
136144
"execution_count": 8,
137-
"metadata": {},
145+
"metadata": {
146+
"collapsed": true
147+
},
138148
"outputs": [],
139149
"source": [
140150
"# Create a list with repeats\n",
@@ -174,7 +184,9 @@
174184
{
175185
"cell_type": "code",
176186
"execution_count": 10,
177-
"metadata": {},
187+
"metadata": {
188+
"collapsed": true
189+
},
178190
"outputs": [],
179191
"source": [
180192
"# Set object to be a boolean\n",
@@ -240,7 +252,9 @@
240252
{
241253
"cell_type": "code",
242254
"execution_count": 13,
243-
"metadata": {},
255+
"metadata": {
256+
"collapsed": true
257+
},
244258
"outputs": [],
245259
"source": [
246260
"# None placeholder\n",
@@ -289,7 +303,7 @@
289303
"name": "python",
290304
"nbconvert_exporter": "python",
291305
"pygments_lexer": "ipython3",
292-
"version": "3.6.2"
306+
"version": "3.6.1"
293307
}
294308
},
295309
"nbformat": 4,

00-Python Object and Data Structure Basics/07-Files.ipynb 00-Python Object and Data Structure Basics/.ipynb_checkpoints/08-Files-checkpoint.ipynb

+82-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"Python has a built-in open function that allows us to open and play with basic file types. First we will need a file though. We're going to use some IPython magic to create a text file!\n",
1212
"\n",
1313
"## IPython Writing a File \n",
14-
"#### This function is specific to jupyter notebooks!"
14+
"#### This function is specific to jupyter notebooks! Alternatively, quickly create a simple .txt file with sublime text editor."
1515
]
1616
},
1717
{
@@ -38,13 +38,80 @@
3838
"source": [
3939
"## Python Opening a file\n",
4040
"\n",
41-
"We can open a file with the open() function. The open function also takes in arguments (also called parameters). Lets see how this is used:"
41+
"Let's being by opening the file test.txt that is located in the same directory as this notebook. For now we will work with files located in the same directory as the notebook or .py script you are using.\n",
42+
"\n",
43+
"It is very easy to get an error on this step:"
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": 1,
49+
"metadata": {},
50+
"outputs": [
51+
{
52+
"ename": "FileNotFoundError",
53+
"evalue": "[Errno 2] No such file or directory: 'whoops.txt'",
54+
"output_type": "error",
55+
"traceback": [
56+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
57+
"\u001b[1;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
58+
"\u001b[1;32m<ipython-input-1-dafe28ee473f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mmyfile\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'whoops.txt'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
59+
"\u001b[1;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'whoops.txt'"
60+
]
61+
}
62+
],
63+
"source": [
64+
"myfile = open('whoops.txt')"
65+
]
66+
},
67+
{
68+
"cell_type": "markdown",
69+
"metadata": {},
70+
"source": [
71+
"To avoid this error,make sure your .txt file is saved in the same location as your notebook, to check your notebook location, use **pwd**:"
4272
]
4373
},
4474
{
4575
"cell_type": "code",
4676
"execution_count": 2,
4777
"metadata": {},
78+
"outputs": [
79+
{
80+
"data": {
81+
"text/plain": [
82+
"'C:\\\\Users\\\\Marcial\\\\Pierian-Data-Courses\\\\Complete-Python-3-Bootcamp\\\\00-Python Object and Data Structure Basics'"
83+
]
84+
},
85+
"execution_count": 2,
86+
"metadata": {},
87+
"output_type": "execute_result"
88+
}
89+
],
90+
"source": [
91+
"pwd"
92+
]
93+
},
94+
{
95+
"cell_type": "markdown",
96+
"metadata": {},
97+
"source": [
98+
"**Alternatively, to grab files from any location on your computer, simply pass in the entire file path. **\n",
99+
"\n",
100+
"For Windows you need to use double \\ so python doesn't treat the second \\ as an escape character, a file path is in the form:\n",
101+
"\n",
102+
" myfile = open(\"C:\\\\Users\\\\YourUserName\\\\Home\\\\Folder\\\\myfile.txt\")\n",
103+
"\n",
104+
"For MacOS and Linux you use slashes in the opposite direction:\n",
105+
"\n",
106+
" myfile = open(\"/Users/YouUserName/Folder/myfile.txt\")"
107+
]
108+
},
109+
{
110+
"cell_type": "code",
111+
"execution_count": 2,
112+
"metadata": {
113+
"collapsed": true
114+
},
48115
"outputs": [],
49116
"source": [
50117
"# Open the text.txt we made earlier\n",
@@ -181,7 +248,9 @@
181248
{
182249
"cell_type": "code",
183250
"execution_count": 8,
184-
"metadata": {},
251+
"metadata": {
252+
"collapsed": true
253+
},
185254
"outputs": [],
186255
"source": [
187256
"my_file.close()"
@@ -199,7 +268,9 @@
199268
{
200269
"cell_type": "code",
201270
"execution_count": 9,
202-
"metadata": {},
271+
"metadata": {
272+
"collapsed": true
273+
},
203274
"outputs": [],
204275
"source": [
205276
"# Add a second argument to the function, 'w' which stands for write.\n",
@@ -262,7 +333,9 @@
262333
{
263334
"cell_type": "code",
264335
"execution_count": 12,
265-
"metadata": {},
336+
"metadata": {
337+
"collapsed": true
338+
},
266339
"outputs": [],
267340
"source": [
268341
"my_file.close() # always do this when you're done with a file"
@@ -321,7 +394,9 @@
321394
{
322395
"cell_type": "code",
323396
"execution_count": 15,
324-
"metadata": {},
397+
"metadata": {
398+
"collapsed": true
399+
},
325400
"outputs": [],
326401
"source": [
327402
"my_file.close()"
@@ -473,7 +548,7 @@
473548
"name": "python",
474549
"nbconvert_exporter": "python",
475550
"pygments_lexer": "ipython3",
476-
"version": "3.6.2"
551+
"version": "3.6.1"
477552
}
478553
},
479554
"nbformat": 4,

0 commit comments

Comments
 (0)