Skip to content

Commit 3a5ce91

Browse files
small changes
1 parent 3080ec7 commit 3a5ce91

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

content/Loops_And_Logic.ipynb

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,18 @@
55
"cell_type": "markdown",
66
"source": [
77
"# Loops, Logic, and Data Structures\n",
8-
"\n",
9-
"- practical project: Fibonacci sequence\n",
10-
"- for loops,\n",
11-
"- while loops,\n",
12-
"- if statements,"
8+
"\n"
139
],
1410
"id": "9c7ff0bbc2c8e91d"
1511
},
1612
{
1713
"metadata": {},
1814
"cell_type": "markdown",
1915
"source": [
20-
"Today we'll be learning about loops and logical functions in Python. These are very handy when you want to iterate through data and perform actions based on a condition.\n",
16+
"Today we'll be learning about loops and logical functions in Python. Loops allow you to perform a specific action multipe time in a row, which can be very handy when you want to iterate through data and perform actions based on a condition. Logical functions allow you to perform an action _if_ a condition is true or not.\n",
2117
"\n",
2218
"## Conditional Operators in Python\n",
23-
"The basics of conditional operators are `if`, `elif`, and `else`. These form the backbone of logic in Python. It's like writing a sentence, \"If Joe likes apples, give him an apple, if he likes something else like oranges, give him an orange. If all else fails, give him a banana.\"\n",
19+
"The basics of conditional operators are `if`, `elif`, and `else`. These form the backbone of logic in Python. It's like writing a sentence, \"If Alex Yin likes apples, give him an apple, if he likes something else like oranges, give him an orange. If all else fails, give him a monster.\"\n",
2420
"\n",
2521
"`if` tells the computer to execute the following code block _if_ a condition is true.<br>\n",
2622
"`elif` tells the computer to execute the following code block _if_ nothing _el_se above was true. (optional, but requires an if)<br>\n",
@@ -71,12 +67,33 @@
7167
"cell_type": "code",
7268
"source": [
7369
"bananas = 8\n",
74-
"eggplants = 2"
70+
"eggplants = 2\n",
71+
"# write your code here"
7572
],
7673
"id": "96b54220aa653219",
7774
"outputs": [],
7875
"execution_count": null
7976
},
77+
{
78+
"metadata": {},
79+
"cell_type": "markdown",
80+
"source": "Try fixing this horrendeously wrong if statement!",
81+
"id": "8034b641777d2cbf"
82+
},
83+
{
84+
"metadata": {},
85+
"cell_type": "code",
86+
"outputs": [],
87+
"execution_count": null,
88+
"source": [
89+
"i like cheese = true\n",
90+
"if i like cheese\n",
91+
" print(i like cheese!)\n",
92+
"else\n",
93+
" print get out of wisconsin!"
94+
],
95+
"id": "6513091686b4e2e0"
96+
},
8097
{
8198
"metadata": {},
8299
"cell_type": "markdown",
@@ -383,7 +400,7 @@
383400
"metadata": {},
384401
"cell_type": "markdown",
385402
"source": [
386-
"# Timing your loops:\n",
403+
"## optional! Timing your loops:\n",
387404
"\n",
388405
"if you want your loops to execute at a specific interval, perhaps to give the illusion of someone typing out on screen, or to perform an action every 10 seconds, you can add a delay at the end of each loop using the `time` library. We're importing the time library, which comes pre-installed. We'll talk more about imports in a later chapter, but we're basically using code that other people have already written to help us in our program."
389406
],

0 commit comments

Comments
 (0)