Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
9 changes: 1 addition & 8 deletions lessons/Part1/01_introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"\n",
"## Coding Strategies\n",
"\n",
"Planning ahead can help mitigate time spent dealing with bugs and errors in code. General steps for defensive coding are:\n",
"Planning ahead can help mitigate time spent dealing with bugs and errors in code. General steps for resilient coding are:\n",
"\n",
"1. State the goals of your code as clearly as possible.\n",
"2. Plan out the general logic of steps needed to achieve the goal.\n",
Expand Down Expand Up @@ -75,13 +75,6 @@
"\n",
"Don't reinvent the wheel - learning how to find the answer to the issues you run into is a critical part of becoming a capable programmer!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
75 changes: 9 additions & 66 deletions lessons/Part1/02_jupyter_notebooks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"source": [
"## Navigating Jupyter Notebooks\n",
"\n",
"In Jupyter Notebooks, code is divided into cells which can each be run separately. This is the main distinction between Jupyter Notebook `.ipynb` format and Python script `.py` format. Running a cell is done with a key combination: `Shift+Enter`. `Shift+Enter` will run the code in the selecte cell and then automatically move to the following cell.\n",
"In Jupyter Notebooks, code is divided into cells which can each be run separately. This is the main distinction between Jupyter Notebook `.ipynb` format and Python script `.py` format. Running a cell is done with a key combination: `Shift+Enter`. `Shift+Enter` will run the code in the selected cell and then automatically move to the following cell.\n",
"\n",
"Try to run the following code using `Shift+Enter` now. \n",
"\n",
Expand All @@ -29,17 +29,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello World!\n"
]
}
],
"outputs": [],
"source": [
"print(\"Hello World!\")"
]
Expand All @@ -57,17 +49,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3\n"
]
}
],
"outputs": [],
"source": [
"a = 1 + 2\n",
"print(a)"
Expand Down Expand Up @@ -132,17 +116,9 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"And three shall be the count.\n"
]
}
],
"outputs": [],
"source": [
"mystring = \"And three shall be the count.\" \n",
"\n",
Expand All @@ -158,17 +134,9 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"And three shall be the count.\n"
]
}
],
"outputs": [],
"source": [
"print(mystring)"
]
Expand Down Expand Up @@ -215,31 +183,6 @@
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Commenting\n",
"\n",
"We will discuss how and why to comment code later in this series, but we will introduce it now because it's useful when you temporarily don't want to run a section of code.\n",
"\n",
"Simply place a pound sign `#` at the beginning of the line, and that line won't run. Any uncommented lines will be treated as code.\n",
"\n",
"Try running the cell below, then comment out `bad_thing`, and run it again. What changes?\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"good_thing = 1+1\n",
"\n",
"This line should be commented\n",
"bad_thing_1 = 'a' * 'b'"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
28 changes: 2 additions & 26 deletions lessons/Part1/03_variables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,6 @@
"print(\"Year:\", year, \".Month:\", month)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In addition, the argument `sep` (short for separator) can be used to control what goes in between each item."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"Year:\", year, \". Month:\", month, sep = '')"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -83,8 +67,7 @@
"\n",
"* Variable names **must** follow a few rules:\n",
" * They cannot start with a digit.\n",
" * They cannot contain spaces, quotation marks, or other punctuation.\n",
" * They *may* contain an underscore (typically used to separate words in long variable names).\n",
" * They cannot contain spaces, quotation marks, or other punctuation (except underscore).\n",
" \n",
"Not following these rules will result in an error in Python. \n",
"\n",
Expand Down Expand Up @@ -178,7 +161,7 @@
"source": [
"## Challenge 2: Words to Code\n",
"\n",
"Translate the following line into code and save the result to a variable. \n",
"Translate the following line into code and save the result to a variable. Start by writing out each operation as a separate step, *then* translate it to code.\n",
"\n",
"Divide 15 by the sum of a and three times b. Multiply the result by 2 and raise it to the 3rd power. What is the result?\n",
"\n",
Expand Down Expand Up @@ -251,13 +234,6 @@
"source": [
"This is a common technique that is used for swapping variables around. However, often we might choose to just use new variables, rather than overwrite the ones here. Can you think of a reason why we might avoid overwriting a variable?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading