Skip to content

Commit 1c7ccc7

Browse files
committed
Formatting code
1 parent 354dd02 commit 1c7ccc7

8 files changed

Lines changed: 127 additions & 107 deletions

notes/A-Introduction_to_iPython_Notebooks.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
"name": "python",
229229
"nbconvert_exporter": "python",
230230
"pygments_lexer": "ipython3",
231-
"version": "3.5.2"
231+
"version": "3.8.2"
232232
}
233233
},
234234
"nbformat": 4,

notes/B-Numeric_Expressions.ipynb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@
138138
"outputs": [],
139139
"source": [
140140
"print(\"power:\")\n",
141-
"print(10**3)\n",
142-
"print(2**5)"
141+
"print(10 ** 3)\n",
142+
"print(2 ** 5)"
143143
]
144144
},
145145
{
@@ -185,7 +185,6 @@
185185
{
186186
"cell_type": "markdown",
187187
"metadata": {
188-
"heading_collapsed": true,
189188
"hidden": true,
190189
"solution2": "hidden",
191190
"solution2_first": true
@@ -236,7 +235,7 @@
236235
},
237236
"source": [
238237
"\n",
239-
"You have a stock that closed at \\$550 on Monday, and then closed at \\$560 on Tuesday. Calculate its daily return: the daily return is defined as the difference in the closing prices, divided by the closing price the day before."
238+
"You have a stock that closed at `$550` on Monday, and then closed at `$560` on Tuesday. Calculate its daily return: the daily return is defined as the difference in the closing prices, divided by the closing price the day before."
240239
]
241240
},
242241
{
@@ -253,7 +252,6 @@
253252
{
254253
"cell_type": "markdown",
255254
"metadata": {
256-
"heading_collapsed": true,
257255
"hidden": true,
258256
"solution2": "hidden",
259257
"solution2_first": true
@@ -324,7 +322,6 @@
324322
{
325323
"cell_type": "markdown",
326324
"metadata": {
327-
"heading_collapsed": true,
328325
"hidden": true,
329326
"solution2": "hidden",
330327
"solution2_first": true
@@ -398,7 +395,7 @@
398395
"outputs": [],
399396
"source": [
400397
"print(\"The value of the deposit will be:\")\n",
401-
"print(10000 * (1 + 3 / 100)**5)"
398+
"print(10000 * (1 + 3 / 100) ** 5)"
402399
]
403400
},
404401
{
@@ -433,7 +430,6 @@
433430
{
434431
"cell_type": "markdown",
435432
"metadata": {
436-
"heading_collapsed": true,
437433
"hidden": true,
438434
"solution2": "hidden",
439435
"solution2_first": true
@@ -514,7 +510,7 @@
514510
"name": "python",
515511
"nbconvert_exporter": "python",
516512
"pygments_lexer": "ipython3",
517-
"version": "3.5.2"
513+
"version": "3.8.2"
518514
}
519515
},
520516
"nbformat": 4,

notes/C1-Variables.ipynb

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"outputs": [],
2424
"source": [
2525
"print(\"The cost of the meal will be:\")\n",
26-
"print(100 + 100 * 8.875/100 + 100 * 20/100)"
26+
"print(100 + 100 * 8.875 / 100 + 100 * 20 / 100)"
2727
]
2828
},
2929
{
@@ -40,7 +40,7 @@
4040
"outputs": [],
4141
"source": [
4242
"print(\"The cost of the meal will be:\")\n",
43-
"print(75 + 75 * 8.875/100 + 75 * 20/100)"
43+
"print(75 + 75 * 8.875 / 100 + 75 * 20 / 100)"
4444
]
4545
},
4646
{
@@ -59,8 +59,8 @@
5959
"outputs": [],
6060
"source": [
6161
"food = 75\n",
62-
"tax = 8.875/100\n",
63-
"tip = 20/100\n",
62+
"tax = 8.875 / 100\n",
63+
"tip = 20 / 100\n",
6464
"cost = food + food * tax + food * tip\n",
6565
"print(\"The cost of the meal will be:\")\n",
6666
"print(cost)"
@@ -105,7 +105,7 @@
105105
"metadata": {},
106106
"outputs": [],
107107
"source": [
108-
"message = 'I love Python...'\n",
108+
"message = \"I love Python...\"\n",
109109
"print(message)\n",
110110
"print(message)\n",
111111
"print(message)\n",
@@ -120,9 +120,9 @@
120120
"source": [
121121
"males = 7\n",
122122
"females = 10\n",
123-
"fraction = males/(males+females)\n",
123+
"fraction = males / (males + females)\n",
124124
"print(\"Percentage of men:\")\n",
125-
"print(100*fraction)"
125+
"print(100 * fraction)"
126126
]
127127
},
128128
{
@@ -146,8 +146,8 @@
146146
"outputs": [],
147147
"source": [
148148
"food = 75\n",
149-
"tax = 8.875/100\n",
150-
"tip = 20/100\n",
149+
"tax = 8.875 / 100\n",
150+
"tip = 20 / 100\n",
151151
"cost = food + food * tax + food * tip\n",
152152
"print(\"The cost of the meal will be:\")\n",
153153
"print(cost)"
@@ -251,7 +251,7 @@
251251
"outputs": [],
252252
"source": [
253253
"# Base scenario\n",
254-
"yearly_value = base_salary + expected_bonus*base_salary + equity/years_vesting\n",
254+
"yearly_value = base_salary + expected_bonus * base_salary + equity / years_vesting\n",
255255
"print(\"The yearly value of this offer is\", yearly_value)"
256256
]
257257
},
@@ -270,11 +270,11 @@
270270
"source": [
271271
"# Same computation as above, but in three steps\n",
272272
"# We start by adding the base_salary in the yearly_value\n",
273-
"yearly_value = base_salary \n",
273+
"yearly_value = base_salary\n",
274274
"# then we add the expected bonus\n",
275-
"yearly_value = yearly_value + expected_bonus*base_salary \n",
275+
"yearly_value = yearly_value + expected_bonus * base_salary\n",
276276
"# and then we add the value of equity\n",
277-
"yearly_value = yearly_value + equity/years_vesting \n",
277+
"yearly_value = yearly_value + equity / years_vesting\n",
278278
"print(\"The yearly value of this offer is\", yearly_value)"
279279
]
280280
},
@@ -298,9 +298,9 @@
298298
"outputs": [],
299299
"source": [
300300
"# Same computation as above, but using the += shorthand\n",
301-
"yearly_value = base_salary \n",
302-
"yearly_value += expected_bonus*base_salary \n",
303-
"yearly_value += 0* equity/years_vesting\n",
301+
"yearly_value = base_salary\n",
302+
"yearly_value += expected_bonus * base_salary\n",
303+
"yearly_value += 0 * equity / years_vesting\n",
304304
"print(\"The yearly value of this offer is\", yearly_value)"
305305
]
306306
},
@@ -350,11 +350,11 @@
350350
"metadata": {},
351351
"outputs": [],
352352
"source": [
353-
"s = 150000 # salary\n",
354-
"b = 0.25 # bonus percentage\n",
355-
"e = 400000 # value of promised equity\n",
356-
"y = 4 # years for vesting equity\n",
357-
"v = s + b*s + e/y # compute the yearly value\n",
353+
"s = 150000 # salary\n",
354+
"b = 0.25 # bonus percentage\n",
355+
"e = 400000 # value of promised equity\n",
356+
"y = 4 # years for vesting equity\n",
357+
"v = s + b * s + e / y # compute the yearly value\n",
358358
"print(\"The yearly value of this offer is\", v)"
359359
]
360360
},
@@ -375,7 +375,7 @@
375375
"b = 0.25\n",
376376
"e = 400000\n",
377377
"y = 4\n",
378-
"v = s + b*s + e/y\n",
378+
"v = s + b * s + e / y\n",
379379
"print(\"The yearly value of this offer is\", v)"
380380
]
381381
},
@@ -396,7 +396,7 @@
396396
"beer = 0.25\n",
397397
"gin = 400000\n",
398398
"vodka = 4\n",
399-
"rum = whiskey + beer*whiskey + gin/vodka\n",
399+
"rum = whiskey + beer * whiskey + gin / vodka\n",
400400
"print(\"The yearly value of this offer is\", rum)"
401401
]
402402
},
@@ -427,7 +427,7 @@
427427
"metadata": {},
428428
"outputs": [],
429429
"source": [
430-
"# 76trombones is illegal because it begins with a number. \n",
430+
"# 76trombones is illegal because it begins with a number.\n",
431431
"# REMOVE THE COMMENT CHARACTER IN THE NEXT LINE TO ATTEMPT\n",
432432
"# 76trombones = 'big parade'"
433433
]
@@ -470,7 +470,7 @@
470470
"metadata": {},
471471
"outputs": [],
472472
"source": [
473-
"# What’s wrong with class? It turns out that class is one of Python’s keywords. \n",
473+
"# What’s wrong with class? It turns out that class is one of Python’s keywords.\n",
474474
"# REMOVE THE COMMENT CHARACTER IN THE NEXT LINE TO ATTEMPT\n",
475475
"# class = 'Introduction to Programming'"
476476
]
@@ -536,7 +536,7 @@
536536
"metadata": {},
537537
"outputs": [],
538538
"source": [
539-
"# print = 100 \n",
539+
"# print = 100\n",
540540
"# print(\"What happened?\")"
541541
]
542542
},
@@ -589,7 +589,7 @@
589589
"name": "python",
590590
"nbconvert_exporter": "python",
591591
"pygments_lexer": "ipython3",
592-
"version": "3.5.2"
592+
"version": "3.8.2"
593593
}
594594
},
595595
"nbformat": 4,

notes/C2-Variables_Exercises.ipynb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
{
4040
"cell_type": "markdown",
4141
"metadata": {
42-
"heading_collapsed": true,
4342
"hidden": true,
4443
"solution2": "hidden",
4544
"solution2_first": true
@@ -134,7 +133,7 @@
134133
"outputs": [],
135134
"source": [
136135
"# So, let's take a look at our code from last time:\n",
137-
"print(\"180 cm is\", int(180//30.48), \"feet and\", round(180%30.48 / 2.54, 1) , \"inches\")"
136+
"print(\"180 cm is\", int(180 // 30.48), \"feet and\", round(180 % 30.48 / 2.54, 1), \"inches\")"
138137
]
139138
},
140139
{
@@ -172,8 +171,8 @@
172171
"print(centimeters, \"cm is\", feet, \"ft and\", inches, \"inches\")\n",
173172
"\n",
174173
"# And if we want to use round instead of int:\n",
175-
"inches = round(centimeters % cm_per_foot / cm_per_in,1)\n",
176-
"print(centimeters, \"cm is\", feet, \"ft and\", inches, \"inches\")\n"
174+
"inches = round(centimeters % cm_per_foot / cm_per_in, 1)\n",
175+
"print(centimeters, \"cm is\", feet, \"ft and\", inches, \"inches\")"
177176
]
178177
},
179178
{
@@ -229,9 +228,9 @@
229228
},
230229
"outputs": [],
231230
"source": [
232-
"v = 5 # miles per hour\n",
233-
"Ta = 32 # air temperature in F\n",
234-
"Twc = 35.74 + 0.6215 * Ta - 35.75 * v**0.16 + 0.4275 * Ta * v**0.16\n",
231+
"v = 5 # miles per hour\n",
232+
"Ta = 32 # air temperature in F\n",
233+
"Twc = 35.74 + 0.6215 * Ta - 35.75 * v ** 0.16 + 0.4275 * Ta * v ** 0.16\n",
235234
"print(\"The windchil index (feels-like) is:\", int(Twc))"
236235
]
237236
},
@@ -342,7 +341,7 @@
342341
"name": "python",
343342
"nbconvert_exporter": "python",
344343
"pygments_lexer": "ipython3",
345-
"version": "3.6.6"
344+
"version": "3.8.2"
346345
}
347346
},
348347
"nbformat": 4,

notes/C3-DataTypes.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"metadata": {},
2121
"outputs": [],
2222
"source": [
23-
"print(1 + 1) # this is an integer"
23+
"print(1 + 1) # this is an integer"
2424
]
2525
},
2626
{
@@ -29,7 +29,7 @@
2929
"metadata": {},
3030
"outputs": [],
3131
"source": [
32-
"print(1.0 + 1) # this is an integer added to a decimal/floating point"
32+
"print(1.0 + 1) # this is an integer added to a decimal/floating point"
3333
]
3434
},
3535
{
@@ -38,7 +38,7 @@
3838
"metadata": {},
3939
"outputs": [],
4040
"source": [
41-
"print(\"1\" + \"1\") # this a string/text "
41+
"print(\"1\" + \"1\") # this a string/text"
4242
]
4343
},
4444
{
@@ -117,7 +117,7 @@
117117
"metadata": {},
118118
"outputs": [],
119119
"source": [
120-
"type(1+1)"
120+
"type(1 + 1)"
121121
]
122122
},
123123
{
@@ -193,7 +193,7 @@
193193
"name": "python",
194194
"nbconvert_exporter": "python",
195195
"pygments_lexer": "ipython3",
196-
"version": "3.5.2"
196+
"version": "3.8.2"
197197
}
198198
},
199199
"nbformat": 4,

0 commit comments

Comments
 (0)