Skip to content

Commit cde7dd3

Browse files
committed
minor updates to lesson 1
1 parent 0592e33 commit cde7dd3

2 files changed

Lines changed: 69 additions & 26 deletions

File tree

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
birth_year = eval(input("What is the birth year for the milestones?"))
1+
birth_year = input("What is the birth year for the milestones?")
22
# raw_input always gives strings, so convert to int
33
birth_year = int(birth_year)
44

@@ -7,6 +7,6 @@
77
drinking_year = birth_year + 21
88
president_year = birth_year + 35
99

10-
print(("You are able to drive in " + str(driving_year)))
11-
print(("You are able to drink in " + str(drinking_year)))
12-
print(("You are able to run for president in " + str(president_year)))
10+
print("You are able to drive in " + str(driving_year))
11+
print("You are able to drink in " + str(drinking_year))
12+
print("You are able to run for president in " + str(president_year))

Lesson01_Variables/lesson01.ipynb

Lines changed: 65 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,33 @@
6565
"print(\"Hello World\")"
6666
]
6767
},
68+
{
69+
"cell_type": "markdown",
70+
"metadata": {},
71+
"source": [
72+
"Jupyter notebooks will always print the value of the last line so you don't have to. You can suppress this with a semicolon ';'"
73+
]
74+
},
75+
{
76+
"cell_type": "code",
77+
"execution_count": null,
78+
"metadata": {},
79+
"outputs": [],
80+
"source": [
81+
"\"Hello World\""
82+
]
83+
},
84+
{
85+
"cell_type": "code",
86+
"execution_count": null,
87+
"metadata": {
88+
"collapsed": true
89+
},
90+
"outputs": [],
91+
"source": [
92+
"\"Hello World\";"
93+
]
94+
},
6895
{
6996
"cell_type": "markdown",
7097
"metadata": {},
@@ -135,7 +162,9 @@
135162
{
136163
"cell_type": "code",
137164
"execution_count": null,
138-
"metadata": {},
165+
"metadata": {
166+
"collapsed": true
167+
},
139168
"outputs": [],
140169
"source": []
141170
},
@@ -192,7 +221,7 @@
192221
"metadata": {},
193222
"outputs": [],
194223
"source": [
195-
"print((3 * 2.1))"
224+
"print(3 * 2.1)"
196225
]
197226
},
198227
{
@@ -210,7 +239,7 @@
210239
"metadata": {},
211240
"outputs": [],
212241
"source": [
213-
"print((5 / 2))"
242+
"print(5 / 2)"
214243
]
215244
},
216245
{
@@ -242,7 +271,9 @@
242271
{
243272
"cell_type": "code",
244273
"execution_count": null,
245-
"metadata": {},
274+
"metadata": {
275+
"collapsed": true
276+
},
246277
"outputs": [],
247278
"source": []
248279
},
@@ -302,7 +333,9 @@
302333
{
303334
"cell_type": "code",
304335
"execution_count": null,
305-
"metadata": {},
336+
"metadata": {
337+
"collapsed": true
338+
},
306339
"outputs": [],
307340
"source": []
308341
},
@@ -320,7 +353,7 @@
320353
"metadata": {},
321354
"outputs": [],
322355
"source": [
323-
"print(('Hello ' + 'Coding Circle'))"
356+
"print('Hello ' + 'Coding Circle')"
324357
]
325358
},
326359
{
@@ -329,7 +362,7 @@
329362
"metadata": {},
330363
"outputs": [],
331364
"source": [
332-
"print((\"The \" + WHALE + \" lives in the sea.\"))"
365+
"print(\"The \" + WHALE + \" lives in the sea.\")"
333366
]
334367
},
335368
{
@@ -345,7 +378,7 @@
345378
"metadata": {},
346379
"outputs": [],
347380
"source": [
348-
"print((\"My name is\" + \"Charlotte\"))"
381+
"print(\"My name is\" + \"Charlotte\")"
349382
]
350383
},
351384
{
@@ -359,7 +392,9 @@
359392
{
360393
"cell_type": "code",
361394
"execution_count": null,
362-
"metadata": {},
395+
"metadata": {
396+
"collapsed": true
397+
},
363398
"outputs": [],
364399
"source": []
365400
},
@@ -369,7 +404,7 @@
369404
"source": [
370405
"## Asking the user for input\n",
371406
"\n",
372-
"To get an input for the user we use the built-in function input() and assign it to a variable.\n",
407+
"To get an input for the user we use the built-in function `input()` and assign it to a variable.\n",
373408
"\n",
374409
"NOTE: The result is always a string."
375410
]
@@ -380,7 +415,7 @@
380415
"metadata": {},
381416
"outputs": [],
382417
"source": [
383-
"my_name = eval(input())\n",
418+
"my_name = input()\n",
384419
"print(my_name)"
385420
]
386421
},
@@ -401,8 +436,8 @@
401436
"metadata": {},
402437
"outputs": [],
403438
"source": [
404-
"favorite_ocean_animal = eval(input(\"What is your favorite sea creature?\\n\"))\n",
405-
"print((\"The \" + favorite_ocean_animal + \" is so cool!\"))"
439+
"favorite_ocean_animal = input(\"What is your favorite sea creature?\\n\")\n",
440+
"print(\"The \" + favorite_ocean_animal + \" is so cool!\")"
406441
]
407442
},
408443
{
@@ -422,9 +457,9 @@
422457
"metadata": {},
423458
"outputs": [],
424459
"source": [
425-
"number_of_apples = eval(input(\"How many apples do you want?\\n\"))\n",
460+
"number_of_apples = input(\"How many apples do you want?\\n\")\n",
426461
"number_of_apples_int = int(number_of_apples)\n",
427-
"print((number_of_apples_int * 1.05))"
462+
"print(number_of_apples_int * 1.05)"
428463
]
429464
},
430465
{
@@ -438,7 +473,9 @@
438473
{
439474
"cell_type": "code",
440475
"execution_count": null,
441-
"metadata": {},
476+
"metadata": {
477+
"collapsed": true
478+
},
442479
"outputs": [],
443480
"source": []
444481
},
@@ -455,13 +492,15 @@
455492
{
456493
"cell_type": "code",
457494
"execution_count": null,
458-
"metadata": {},
495+
"metadata": {
496+
"collapsed": true
497+
},
459498
"outputs": [],
460499
"source": [
461500
"# Calculate the price of apples that a user wants\n",
462-
"number_of_apples = eval(input(\"How many apples do you want?\\n\")) # Ask user for quantity of apples\n",
501+
"number_of_apples = input(\"How many apples do you want?\\n\") # Ask user for quantity of apples\n",
463502
"number_of_apples_int = int(number_of_apples) # raw_input returns string, so convert to integer\n",
464-
"print((number_of_apples_int * 1.05)) # multiply by price of apples"
503+
"print(number_of_apples_int * 1.05) # multiply by price of apples"
465504
]
466505
},
467506
{
@@ -475,7 +514,9 @@
475514
{
476515
"cell_type": "code",
477516
"execution_count": null,
478-
"metadata": {},
517+
"metadata": {
518+
"collapsed": true
519+
},
479520
"outputs": [],
480521
"source": []
481522
},
@@ -497,7 +538,9 @@
497538
{
498539
"cell_type": "code",
499540
"execution_count": null,
500-
"metadata": {},
541+
"metadata": {
542+
"collapsed": true
543+
},
501544
"outputs": [],
502545
"source": [
503546
"\n",
@@ -521,7 +564,7 @@
521564
"name": "python",
522565
"nbconvert_exporter": "python",
523566
"pygments_lexer": "ipython3",
524-
"version": "3.6.1"
567+
"version": "3.6.3"
525568
}
526569
},
527570
"nbformat": 4,

0 commit comments

Comments
 (0)