Skip to content

Commit 51e1394

Browse files
author
giumas
committed
first release
1 parent 52f34b8 commit 51e1394

8 files changed

+115
-173
lines changed

006_Read_and_Write_Text_Files.ipynb

+10-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@
298298
"source": [
299299
"From the [Lists of Variables notebook](002_Lists_of_Variables.ipynb), you know how to access an item in a list by its index. \n",
300300
"\n",
301-
"Thus, to access the file name `sal.txt`, we can use `1` as index since it is the **second** element in the list."
301+
"In this particular case, to access the file name `sal.txt`, we will use `1` as index since it is the **second** element in the `retrieved_paths` list."
302302
]
303303
},
304304
{
@@ -311,6 +311,15 @@
311311
"print(\"The file path with index 1 is: \" + sal_path)"
312312
]
313313
},
314+
{
315+
"cell_type": "markdown",
316+
"metadata": {},
317+
"source": [
318+
"<img align=\"left\" width=\"6%\" style=\"padding-right:10px;\" src=\"images/key.png\">\n",
319+
"\n",
320+
"**CAUTION**: The above solution works **specifically** with the current directory content. For instance, changing the directory content may alter the index of the salinity file in the list, thus breaking your code."
321+
]
322+
},
314323
{
315324
"cell_type": "markdown",
316325
"metadata": {},

007_Dictionaries_and_Metadata.ipynb

+3-3
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@
540540
"metadata = dict()\n",
541541
"metadata[\"first_name\"] = \"John\"\n",
542542
"\n",
543-
"print(\"The first name is: %s\" % (metadata[\"first_name\"], ))"
543+
"print(\"The first name is: %s\" % (metadata[\"first_name\"]))"
544544
]
545545
},
546546
{
@@ -555,7 +555,7 @@
555555
"metadata[\"start_timestamp\"] = datetime(2019, 2, 22, 12, 32, 40)\n",
556556
"\n",
557557
"print(\"The position is: %s, %s\" % (metadata[\"latitude\"], metadata[\"longitude\"]))\n",
558-
"print(\"Start time: %s\" % (metadata[\"start_timestamp\"], ))"
558+
"print(\"Start time: %s\" % (metadata[\"start_timestamp\"]))"
559559
]
560560
},
561561
{
@@ -575,7 +575,7 @@
575575
"<img align=\"left\" width=\"6%\" style=\"padding-right:10px;\" src=\"images/info.png\">\n",
576576
"\n",
577577
"In the above code, the values inside the rounded brackets after the `%` operator create a so-called [`tuple`](https://docs.python.org/3.6/library/stdtypes.html?#tuples). <br>\n",
578-
"A `tuple` is a Python container that represents an immutable sequence (thus, you cannot change the content of a `tuple`)."
578+
"A `tuple` is a Python container similar to a list except that you cannot modify the content after creation (an **immutable sequence**)."
579579
]
580580
},
581581
{

008_A_Class_as_a_Data_Container.ipynb

+23-31
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
"cell_type": "markdown",
2020
"metadata": {},
2121
"source": [
22-
"It is time to learn how to define your own type! "
22+
"You encountered several data types. Sometimes you may need a custom type. So it is time to learn how to define your own data type! "
2323
]
2424
},
2525
{
2626
"cell_type": "markdown",
2727
"metadata": {},
2828
"source": [
29-
"Creating your own type is a bit more complicated than writing functions, but it comes with big advantages that will be apparent soon."
29+
"Creating your own data type is a bit more complicated than writing functions, but it comes with big advantages that soon will be apparent."
3030
]
3131
},
3232
{
@@ -58,21 +58,21 @@
5858
"cell_type": "markdown",
5959
"metadata": {},
6060
"source": [
61-
"However, this notebook will only use a class as a data container. And we will learn it by example. "
61+
"This notebook will **only** use a class as a data container. And you will learn by example. "
6262
]
6363
},
6464
{
6565
"cell_type": "markdown",
6666
"metadata": {},
6767
"source": [
68-
"## Class Definition and Instantiation"
68+
"## Class Definition"
6969
]
7070
},
7171
{
7272
"cell_type": "markdown",
7373
"metadata": {},
7474
"source": [
75-
"Assuming that we want to create a class that is able to hold the content of the `sal.txt` file cited in a [previous notebook](006_Read_and_Write_Text_Files.ipynb). As such, we will call this new class `SalinityData`."
75+
"We want to create a class that is able to hold the content of the `sal.txt` file cited in a [previous notebook](006_Read_and_Write_Text_Files.ipynb). We will give this class the meaningful name of `SalinityData`."
7676
]
7777
},
7878
{
@@ -96,14 +96,14 @@
9696
"cell_type": "markdown",
9797
"metadata": {},
9898
"source": [
99-
"The first line of the above code contains: the `class` keyword, the class name (`SalinityData`), and a `:`."
99+
"The first line of the above code contains: the `class` keyword, the class name (`SalinityData`), and a `:`"
100100
]
101101
},
102102
{
103103
"cell_type": "markdown",
104104
"metadata": {},
105105
"source": [
106-
"The second line is a special text, called `docstring`, that provides a brief description of the class. The description is between `\"\"\" \"\"\"` (i.e., triple quotes)."
106+
"The second line is a special descriptive text, called `docstring`, that provides a brief explanation about the class. The description is between `\"\"\" \"\"\"` (i.e., triple quotes)."
107107
]
108108
},
109109
{
@@ -119,7 +119,7 @@
119119
"cell_type": "markdown",
120120
"metadata": {},
121121
"source": [
122-
"Once defined, we can create an instance of the `SalinityData` class, by calling it with `()` at the end:"
122+
"Once defined, we can create an object (**instance**) of the `SalinityData` class, by calling it with `()` at the end:"
123123
]
124124
},
125125
{
@@ -162,14 +162,14 @@
162162
"cell_type": "markdown",
163163
"metadata": {},
164164
"source": [
165-
"Because the `SalinityData` class is defined in this \"main\" notebook, the full name of the type is `__main__.SalinityData`"
165+
"Because the `SalinityData` class is defined in this notebook, the full name of the type is `__main__.SalinityData`. At this stage of learning Python, you can safely ignore the `__main__.` part."
166166
]
167167
},
168168
{
169169
"cell_type": "markdown",
170170
"metadata": {},
171171
"source": [
172-
"At the moment, this new defined class is not that exciting. We will soon start to populate it with a number of useful **attributes** and **methods**."
172+
"At the moment, this newly defined class is not that exciting. We will soon start to populate it with a number of useful **attributes** and **methods**."
173173
]
174174
},
175175
{
@@ -178,7 +178,7 @@
178178
"source": [
179179
"<img align=\"left\" width=\"6%\" style=\"padding-right:10px;\" src=\"images/key.png\">\n",
180180
"\n",
181-
"The **class attributes** are used to maintain the state of each class instance. The **class methods** may modify the attributes and thus its state."
181+
"The **class attributes** are variables that capture all the information describing the class. Thus, **class attributes** maintain the **state** of each class instance. The **class methods** may modify the attributes and thus its state."
182182
]
183183
},
184184
{
@@ -187,7 +187,7 @@
187187
"source": [
188188
"<img align=\"left\" width=\"6%\" style=\"padding-right:10px;\" src=\"images/key.png\">\n",
189189
"\n",
190-
"The **methods** definition **always** has `self` as first parameter. The `self` is absent in the generic **functions** that we have seen in the [Write Your Own Functions notebook](005_Write_Your_Own_Functions.ipynb)."
190+
"The **class methods** definition must **always** have `self` as first parameter."
191191
]
192192
},
193193
{
@@ -203,14 +203,14 @@
203203
"source": [
204204
"<img align=\"left\" width=\"6%\" style=\"padding-right:10px;\" src=\"images/key.png\">\n",
205205
"\n",
206-
"The **class initialization** happens within a special method called `__init__(self)`. "
206+
"The **class initialization** is done by a special method called `__init__(self)`. "
207207
]
208208
},
209209
{
210210
"cell_type": "markdown",
211211
"metadata": {},
212212
"source": [
213-
"If you don't provide a `__init__(self)` method (like in the above code), Python will create an implicit one for you."
213+
"If you don't provide a `__init__(self)` method (like in the code below), Python will create one for you behind the scenes (**implicitly**)."
214214
]
215215
},
216216
{
@@ -262,27 +262,19 @@
262262
},
263263
{
264264
"cell_type": "code",
265-
"execution_count": 13,
266-
"metadata": {},
267-
"outputs": [
268-
{
269-
"name": "stdout",
270-
"output_type": "stream",
271-
"text": [
272-
"Salinity values: []\n"
273-
]
274-
}
275-
],
265+
"execution_count": null,
266+
"metadata": {},
267+
"outputs": [],
276268
"source": [
277269
"sal_data = SalinityData()\n",
278-
"print(\"Salinity values: %s\" % (sal_data.sal_values, ))"
270+
"print(\"Salinity values: %s\" % (sal_data.sal_values))"
279271
]
280272
},
281273
{
282274
"cell_type": "markdown",
283275
"metadata": {},
284276
"source": [
285-
"The above code prints that the list content is `[]`. This is not surprising since the list was created empty in the `__init__(self)` method."
277+
"The above code prints the list content as `[]`. This is not surprising since an empty list was created in the `__init__(self)` method."
286278
]
287279
},
288280
{
@@ -308,7 +300,7 @@
308300
"source": [
309301
"<img align=\"left\" width=\"6%\" style=\"padding-right:10px;\" src=\"images/test.png\">\n",
310302
"\n",
311-
"Write a class for a `TemperatureData` with functionalities similar to the above `SalinityData`. Then, add the code to demonstrate its functionalities."
303+
"Write a `TemperatureData` class definition similar to the above `SalinityData`. Then, create an instance of that class and print the temperature values."
312304
]
313305
},
314306
{
@@ -348,7 +340,7 @@
348340
"cell_type": "markdown",
349341
"metadata": {},
350342
"source": [
351-
"There is much more that you can do with a class, but this is the amount of information that you need to complete this training. "
343+
"There is much more that you can do with a class, but this is the amount of information that you need to complete this *Programming Basics with Python* training. "
352344
]
353345
},
354346
{
@@ -357,7 +349,7 @@
357349
"source": [
358350
"<img align=\"left\" width=\"6%\" style=\"padding-right:10px;\" src=\"images/info.png\">\n",
359351
"\n",
360-
"If you are eager to know more about classes, you may read [this supplemental notebook](SUP_First_Steps_of_a_Class.ipynb)."
352+
"If you are interested in learning more about classes, you may read [this supplemental notebook](SUP_First_Steps_of_a_Class.ipynb)."
361353
]
362354
},
363355
{
@@ -398,7 +390,7 @@
398390
"metadata": {},
399391
"source": [
400392
"<!--NAVIGATION-->\n",
401-
"[< Dictionaries and Metadata](007_Dictionaries_and_Metadata.ipynb) | [Contents](index.ipynb) | [Wrapping Up Notions >](009_Wrapping_Up_Notions.ipynb)"
393+
"[< Dictionaries and Metadata](007_Dictionaries_and_Metadata.ipynb) | [Contents](index.ipynb) | [Summing-Up >](009_Summing-Up.ipynb)"
402394
]
403395
}
404396
],

0 commit comments

Comments
 (0)