Skip to content

Commit 566ae32

Browse files
authored
Merge pull request #1 from scriptotek/eirill-changes
general updates
2 parents ecc40e8 + df84392 commit 566ae32

10 files changed

+312
-1587
lines changed

01_basics.ipynb

Lines changed: 52 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
"cell_type": "markdown",
1313
"metadata": {},
1414
"source": [
15-
"## Printing to the screen (terminal)\n",
15+
"## Printing to the Screen (Terminal)\n",
1616
"In Python, you can use the function `print()` to display things on the screen.\n",
1717
"Put the item to be printed inside the parentheses."
1818
]
1919
},
2020
{
2121
"cell_type": "code",
2222
"execution_count": null,
23-
"metadata": {
24-
"collapsed": true
25-
},
23+
"metadata": {},
2624
"outputs": [],
2725
"source": [
2826
"print(2)"
@@ -38,9 +36,7 @@
3836
{
3937
"cell_type": "code",
4038
"execution_count": null,
41-
"metadata": {
42-
"collapsed": true
43-
},
39+
"metadata": {},
4440
"outputs": [],
4541
"source": [
4642
"print(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)"
@@ -56,9 +52,7 @@
5652
{
5753
"cell_type": "code",
5854
"execution_count": null,
59-
"metadata": {
60-
"collapsed": true
61-
},
55+
"metadata": {},
6256
"outputs": [],
6357
"source": [
6458
"print(\"This message will be printed\")"
@@ -80,9 +74,7 @@
8074
{
8175
"cell_type": "code",
8276
"execution_count": null,
83-
"metadata": {
84-
"collapsed": true
85-
},
77+
"metadata": {},
8678
"outputs": [],
8779
"source": [
8880
"a = 2\n",
@@ -91,7 +83,7 @@
9183
"print(\"2: b =\", b)\n",
9284
"a = a + 2\n",
9385
"print(\"3: a =\", a)\n",
94-
"print(\"4: b =\", b)\n"
86+
"print(\"4: b =\", b)"
9587
]
9688
},
9789
{
@@ -123,9 +115,7 @@
123115
{
124116
"cell_type": "code",
125117
"execution_count": null,
126-
"metadata": {
127-
"collapsed": true
128-
},
118+
"metadata": {},
129119
"outputs": [],
130120
"source": [
131121
"VARIABLE_NAME_with_1_2_3 = 0"
@@ -143,9 +133,7 @@
143133
{
144134
"cell_type": "code",
145135
"execution_count": null,
146-
"metadata": {
147-
"collapsed": true
148-
},
136+
"metadata": {},
149137
"outputs": [],
150138
"source": [
151139
"pi = 3.14\n",
@@ -157,7 +145,26 @@
157145
"cell_type": "markdown",
158146
"metadata": {},
159147
"source": [
160-
"## Variables as sticky notes\n",
148+
"### <span style=\"color:green\"> Exercise: Variable Names </span>\n",
149+
"\n",
150+
"Why does the code below yield an error? Fix the code such that the name is printed."
151+
]
152+
},
153+
{
154+
"cell_type": "code",
155+
"execution_count": null,
156+
"metadata": {},
157+
"outputs": [],
158+
"source": [
159+
"name = \"Arthur\"\n",
160+
"print(Name)"
161+
]
162+
},
163+
{
164+
"cell_type": "markdown",
165+
"metadata": {},
166+
"source": [
167+
"## Variables as Sticky Notes\n",
161168
"\n",
162169
"Python variables are *independent* from each other.\n",
163170
"Let's define two variables. Alice is 20 years old, and her classmate Bob is the same age:"
@@ -166,9 +173,7 @@
166173
{
167174
"cell_type": "code",
168175
"execution_count": null,
169-
"metadata": {
170-
"collapsed": true
171-
},
176+
"metadata": {},
172177
"outputs": [],
173178
"source": [
174179
"alice_age = 20\n",
@@ -185,9 +190,7 @@
185190
{
186191
"cell_type": "code",
187192
"execution_count": null,
188-
"metadata": {
189-
"collapsed": true
190-
},
193+
"metadata": {},
191194
"outputs": [],
192195
"source": [
193196
"alice_age = 21\n",
@@ -210,7 +213,7 @@
210213
"cell_type": "markdown",
211214
"metadata": {},
212215
"source": [
213-
"## Python as calculator \n",
216+
"## Python as a Calculator \n",
214217
"You can do simple math like this:\n",
215218
"\n",
216219
"$\\Large{\\cdot}$ $a - b$ in Python : `a - b` \n",
@@ -225,9 +228,7 @@
225228
{
226229
"cell_type": "code",
227230
"execution_count": null,
228-
"metadata": {
229-
"collapsed": true
230-
},
231+
"metadata": {},
231232
"outputs": [],
232233
"source": [
233234
"a = 1\n",
@@ -244,7 +245,7 @@
244245
"cell_type": "markdown",
245246
"metadata": {},
246247
"source": [
247-
"## Exercise: understanding variables\n",
248+
"### <span style=\"color:green\"> Exercise: Understanding Variables </span>\n",
248249
"\n",
249250
"Go through the following lines of code step-by-step.\n",
250251
"What are the values of the different variables after each step?\n",
@@ -254,9 +255,7 @@
254255
{
255256
"cell_type": "code",
256257
"execution_count": null,
257-
"metadata": {
258-
"collapsed": true
259-
},
258+
"metadata": {},
260259
"outputs": [],
261260
"source": [
262261
"length = 100\n",
@@ -270,7 +269,7 @@
270269
"cell_type": "markdown",
271270
"metadata": {},
272271
"source": [
273-
"## Exercise: using variables\n",
272+
"### <span style=\"color:green\"> Exercise: Using Variables </span>\n",
274273
"\n",
275274
"Alice weighs 65 kg, and Bob weighs 70 kg.\n",
276275
"1. Create variables containing these data. Try to think of descriptive variable names.\n",
@@ -292,17 +291,15 @@
292291
"cell_type": "markdown",
293292
"metadata": {},
294293
"source": [
295-
"### Integers (whole numbers)\n",
294+
"### Integers (Whole Numbers)\n",
296295
"\n",
297296
"In Python a whole number is called an *integer*, but when programming we use the abbreviation `int`."
298297
]
299298
},
300299
{
301300
"cell_type": "code",
302301
"execution_count": null,
303-
"metadata": {
304-
"collapsed": true
305-
},
302+
"metadata": {},
306303
"outputs": [],
307304
"source": [
308305
"print(type(2))"
@@ -312,17 +309,15 @@
312309
"cell_type": "markdown",
313310
"metadata": {},
314311
"source": [
315-
"### Float (decimal numbers)\n",
312+
"### Float (Decimal Numbers)\n",
316313
"\n",
317314
"A decimal number is called a `floating point number`, but when programming it is abbreviated `float`."
318315
]
319316
},
320317
{
321318
"cell_type": "code",
322319
"execution_count": null,
323-
"metadata": {
324-
"collapsed": true
325-
},
320+
"metadata": {},
326321
"outputs": [],
327322
"source": [
328323
"print(type(1.2))"
@@ -332,7 +327,7 @@
332327
"cell_type": "markdown",
333328
"metadata": {},
334329
"source": [
335-
"### String (text) \n",
330+
"### String (Text) \n",
336331
"\n",
337332
"In Python, text is called *String*, abbreviated `str`. \n",
338333
"\n",
@@ -343,9 +338,7 @@
343338
{
344339
"cell_type": "code",
345340
"execution_count": null,
346-
"metadata": {
347-
"collapsed": true
348-
},
341+
"metadata": {},
349342
"outputs": [],
350343
"source": [
351344
"print(type(\"spam\"))"
@@ -364,9 +357,7 @@
364357
{
365358
"cell_type": "code",
366359
"execution_count": null,
367-
"metadata": {
368-
"collapsed": true
369-
},
360+
"metadata": {},
370361
"outputs": [],
371362
"source": [
372363
"print(spam)"
@@ -376,17 +367,15 @@
376367
"cell_type": "markdown",
377368
"metadata": {},
378369
"source": [
379-
"### Exercise: datatypes\n",
370+
"### <span style=\"color:green\">Exercise: datatypes</span>\n",
380371
"\n",
381372
"Can you change the variables below, so that all three contains the value 2, but with different datatypes?"
382373
]
383374
},
384375
{
385376
"cell_type": "code",
386377
"execution_count": null,
387-
"metadata": {
388-
"collapsed": true
389-
},
378+
"metadata": {},
390379
"outputs": [],
391380
"source": [
392381
"int_2 = ?\n",
@@ -396,9 +385,7 @@
396385
{
397386
"cell_type": "code",
398387
"execution_count": null,
399-
"metadata": {
400-
"collapsed": true
401-
},
388+
"metadata": {},
402389
"outputs": [],
403390
"source": [
404391
"float_2 = ?\n",
@@ -408,9 +395,7 @@
408395
{
409396
"cell_type": "code",
410397
"execution_count": null,
411-
"metadata": {
412-
"collapsed": true
413-
},
398+
"metadata": {},
414399
"outputs": [],
415400
"source": [
416401
"str_2 = ?\n",
@@ -421,7 +406,7 @@
421406
"cell_type": "markdown",
422407
"metadata": {},
423408
"source": [
424-
"## Importing libraries/modules\n",
409+
"## Importing Libraries/Modules\n",
425410
"\n",
426411
"A module is a collection of functions that someone has written. A library is a collection of modules.\n",
427412
"There are innumerable python libraries available for performing diverse tasks.\n",
@@ -439,9 +424,7 @@
439424
{
440425
"cell_type": "code",
441426
"execution_count": null,
442-
"metadata": {
443-
"collapsed": true
444-
},
427+
"metadata": {},
445428
"outputs": [],
446429
"source": [
447430
"import math\n",
@@ -465,9 +448,7 @@
465448
{
466449
"cell_type": "code",
467450
"execution_count": null,
468-
"metadata": {
469-
"collapsed": true
470-
},
451+
"metadata": {},
471452
"outputs": [],
472453
"source": [
473454
"from math import pi, sin\n",
@@ -478,7 +459,7 @@
478459
"cell_type": "markdown",
479460
"metadata": {},
480461
"source": [
481-
"## Commenting code\n",
462+
"## Commenting Code\n",
482463
"\n",
483464
"Comments can make your code easier to understand. You can use a `#` character to start a single line comment. \n",
484465
"To write a comment consisting of multiple lines, you use three quotes `'''` before and after the comment."
@@ -487,9 +468,7 @@
487468
{
488469
"cell_type": "code",
489470
"execution_count": null,
490-
"metadata": {
491-
"collapsed": true
492-
},
471+
"metadata": {},
493472
"outputs": [],
494473
"source": [
495474
"# This is how to make a comment on a single line\n",
@@ -535,7 +514,7 @@
535514
"name": "python",
536515
"nbconvert_exporter": "python",
537516
"pygments_lexer": "ipython3",
538-
"version": "3.6.3"
517+
"version": "3.6.8"
539518
}
540519
},
541520
"nbformat": 4,

0 commit comments

Comments
 (0)