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.
2 changes: 1 addition & 1 deletion lessons/Part1/01_introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"<img src=\"https://img.devrant.com/devrant/rant/r_2047080_QRtAy.jpg\" width=\"200\"/>\n",
"</div>\n",
"\n",
"When you're programming, 80% or more of your time will be spent debugging, looking stuff up (like program-specific syntax, [documentation](https://github.com/dlab-berkeley/python-intensive/blob/master/Glossary.md#documentation) for packages, useful functions, etc.), or testing. Relatively little time is actually spent typing out the code - most of it goes into the thinking, planning, and testing to ensure well-designed code!\n",
"When you're programming, 80% or more of your time will be spent debugging, looking stuff up (like program-specific syntax, [documentation](https://github.com/dlab-berkeley/python-intensive/blob/master/glossary.md#documentation) for packages, useful functions, etc.), or testing. Relatively little time is actually spent typing out the code - most of it goes into the thinking, planning, and testing to ensure well-designed code!\n",
"\n",
"## Coding Strategies\n",
"\n",
Expand Down
56 changes: 12 additions & 44 deletions lessons/Part1/02_jupyter_notebooks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -48,7 +40,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If you hit `Enter` only, Jupyter Notebook gives you another line in the current cell.\n",
"**Note:** If you hit `Enter` only, Jupyter Notebook gives you another line in the current cell.\n",
"\n",
"This allows you to compose multi-line commands and submit them to Python all at once.\n",
"\n",
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 @@ -225,7 +193,7 @@
"\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"
"Try running the cell below, then comment out the last two lines and run it again. What changes?\n"
]
},
{
Expand All @@ -246,11 +214,11 @@
"source": [
"### Indenting\n",
"\n",
"Consistent indentation is essential in Python. Python pays close attention to blankspaces, and uses this to understand how you're structuring code. So, you're only supposed to add spaces or indents in places where Python expects you to - otherwise, you'll run into an error.\n",
"Consistent indentation is essential in Python. Python pays close attention to blank spaces, and uses this to understand how you're structuring code. So, you're only supposed to add spaces or indents in places where Python expects you to - otherwise, you'll run into an error.\n",
"\n",
"To move multiple lines of code at once, you can select them and then hit `Control + ]` to indent them (move to the right), or `Control + [` to dedent them to the left.\n",
"\n",
"For Macs, use `Command` in place of `Control`.\n",
"**Note:** For Macs, use `Command` in place of `Control`.\n",
"\n",
"Read the error message down below. What is the error type? How can we fix it?"
]
Expand Down
49 changes: 6 additions & 43 deletions lessons/Part1/03_variables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To print multiple values, separate each item to print with a space."
"Print statements are super useful pieces of code to get a window into what values a variable has. To print multiple values, separate each item to print with a space."
]
},
{
Expand All @@ -61,7 +61,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In addition, the argument `sep` (short for separator) can be used to control what goes in between each item."
"In addition, the argument `sep` (short for separator) can be used to control what goes in between each item. What will the following line of code return?"
]
},
{
Expand Down Expand Up @@ -142,7 +142,7 @@
"* **Operators** (special symbols that perform calculations) are shown in purple in a Jupyter Notebook. These are special symbols that tell Python to perform certain operations.\n",
"* **Functions** are processes that perform multiple operations on variables. We will cover these in a later notebook. \n",
"\n",
"Let's check out some common operations below. Note what values get substituted in for the variables in each operation. "
"Let's check out some common operations below. Predict the outputs of each of the lines of code below. Note what values get substituted in for the variables in each operation. "
]
},
{
Expand Down Expand Up @@ -176,41 +176,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Challenge 2: Words to Code\n",
"\n",
"Translate the following line into code and save the result to a variable. \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",
"**Hint**: Order of operations applies in Python (i.e., PEMDAS)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a = 2\n",
"b = 3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"How many lines of code did you do the challenge in? Can you do it in a single line? What did you name your variable?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Challenge 3: Swapping Values\n",
"## Challenge 2: Swapping Values\n",
"\n",
"Let's say we have two variables and we want to swap the values for each of them. \n",
"\n",
"Does the following method accomplish the goal? What is the value of first and last at the end of the cell? `"
"Does the following method accomplish the goal? (**Hint**: What is the value of first and last at the end of the cell?) `"
]
},
{
Expand Down Expand Up @@ -249,15 +219,8 @@
"cell_type": "markdown",
"metadata": {},
"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?"
"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? How about a reason why we *would* overwrite a variable?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading