Skip to content

Commit

Permalink
Fall22update (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Nardi authored Nov 13, 2022
1 parent 5afd35f commit 420ddd7
Show file tree
Hide file tree
Showing 35 changed files with 2,334 additions and 357 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@
# IPython
profile_default/
ipython_config.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Misc
.vscode/
.venv/
.mypy_cache/

28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.PHONY: all
all: help

# --------------------------------------------

.PHONY: clean
clean: ## Remove cached files and build products
@echo Cleaning caches and build products
@find . -type d -name .mypy_cache -exec rm -rf {} \; -prune
@find . -type d -name __pycache__ -exec rm -rf {} \; -prune
@find . -type d -name .ipynb_checkpoints -exec rm -rf {} \; -prune
@echo Cleaning complete

# --------------------------------------------

.PHONY: reset
reset: clean ## clean, then remove .venv and .mypy cache
@echo Resetting project state
rm -rf .mypy_cache .venv

# --------------------------------------------

.PHONY: help
help: ## Show help
@echo Please specify a target. Choices are:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk \
'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
9 changes: 7 additions & 2 deletions content/00_tableOfContents.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.10.6 64-bit",
"language": "python",
"name": "python3"
},
Expand All @@ -127,7 +127,12 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.10.6"
},
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
}
},
"nbformat": 4,
Expand Down
21 changes: 17 additions & 4 deletions content/01_intro00.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"This is a Python Program\n"
]
}
],
"source": [
"print(\"This is a Python Program\")\n"
]
Expand Down Expand Up @@ -229,7 +237,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3.10.6 64-bit",
"language": "python",
"name": "python3"
},
Expand All @@ -243,7 +251,12 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.6"
},
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
}
},
"nbformat": 4,
Expand Down
118 changes: 60 additions & 58 deletions content/01_intro01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Welcome To Python!"
"# Welcome To Python!\n"
]
},
{
Expand All @@ -14,10 +14,10 @@
"Python provides a modern, flexible programming environment that scales from\n",
"introductory programming courses, to full-fledged enterprise applications.\n",
"It's a great place to start if you want to learn how to write computer programs\n",
"and it runs on just about any system you might have (Windows, Mac, Linux). If\n",
"you're curious about the history of Python (*for example, why is it called\n",
"Python?*) then please visit [The Python History\n",
"Wiki](https://en.wikipedia.org/wiki/History_of_Python):"
"and it runs on just about any system you might have (Windows, Mac, Linux). If\n",
"you're curious about the history of Python (_for example, why is it called\n",
"Python?_) then please visit [The Python History\n",
"Wiki](https://en.wikipedia.org/wiki/History_of_Python):\n"
]
},
{
Expand All @@ -28,8 +28,8 @@
"\n",
"No introduction to computer programming would complete without writing the\n",
"wildly popular [Hello\n",
"World](https://en.wikipedia.org/wiki/%22Hello,_World!%22_program) program. The\n",
"complete program in Python looks like this:"
"World](https://en.wikipedia.org/wiki/%22Hello,_World!%22_program) program. The\n",
"complete program in Python looks like this:\n"
]
},
{
Expand All @@ -49,10 +49,10 @@
"<img src=\"../images/00check.png\" align=\"left\" />\n",
"<br clear=\"all\" />\n",
"\n",
"Do you remember how to run a code cell? Visit [this jupyter\n",
"Do you remember how to run a code cell? Visit [this jupyter\n",
"notebook](./01_intro00.ipynb) if you need a refresher. To test your knowledge,\n",
"run the code cell above and observe the output. Then modify the program to\n",
"print your name, rather than `Hello World` and run it again."
"run the code cell above and observe the output. Then modify the program to\n",
"print your name, rather than `Hello World`, and run it again.\n"
]
},
{
Expand All @@ -63,7 +63,7 @@
"Having Python print information to the screen. A computer program that only\n",
"calculated results, but never provided them to you would not be very useful.\n",
"\n",
"In the [first notebook](01_intro00.ipynb) we introduced this Python program:"
"In the [first notebook](01_intro00.ipynb) we introduced this Python program:\n"
]
},
{
Expand All @@ -80,7 +80,7 @@
"metadata": {},
"source": [
"It's your turn. Modify the program above to print the sum of the first 10 even\n",
"integers (starting from 2). When you run your updated program do you get 110?"
"integers (starting from 2). When you run your updated program do you get `110`?\n"
]
},
{
Expand All @@ -90,7 +90,7 @@
"### Comments\n",
"\n",
"There's a particular name for the file that contains your code. Programmers\n",
"call it *source code* (or a *source file*). A *source file* contains the\n",
"call it _source code_ (or a _source file_). A _source file_ contains the\n",
"instructions that you write directing the computer to perform specific\n",
"operations. Occasionally you'll write a section of code that requires some\n",
"comments to describe your thinking when you wrote it. These aren't executable\n",
Expand All @@ -100,8 +100,8 @@
"you pick up your train of thought. You can also use comments to mark areas of\n",
"your code as \"To Do\" items; things that you'll get back to later.\n",
"\n",
"In Python, non-executable comments are delineated with the hashtag character\n",
"(`#`). Here's an example (run it to see what prints):"
"In Python, non-executable comments are delineated with a leading hashtag\n",
"character (`#`). Here's an example (run it to see what prints):\n"
]
},
{
Expand All @@ -120,7 +120,7 @@
"metadata": {},
"source": [
"Notice that line 2 in the code above is blank. Python ignores blank lines, but\n",
"using them to format your code can make it neater and easier to read."
"using them to format your code can make it neater and easier to read.\n"
]
},
{
Expand All @@ -129,22 +129,22 @@
"source": [
"### Speaking of Spaces\n",
"\n",
"If you can put blanks (spaces) between lines of code, what about spaces within\n",
"a single line of code?\n",
"If you can put blanks (spaces) between lines of code, what about spaces\n",
"*within* a single line of code?\n",
"\n",
"Python is quite forgiving about how things are spaced-out. If often comes down\n",
"Python is quite forgiving about how things are spaced-out. It often comes down\n",
"to readability. Can you (or your instructor) easily read your code and follow\n",
"along? While the program may run just fine, be mindful that you can change the\n",
"intended result because of the particular spacing you used.\n",
"\n",
"Below are some examples. Run them and observe the outputs."
"Below are some examples. Run them and observe the outputs.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Sample 1"
"#### Sample 1\n"
]
},
{
Expand All @@ -166,7 +166,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Sample 2"
"#### Sample 2\n"
]
},
{
Expand All @@ -186,16 +186,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"You should have seen a difference. Python is explicitly complying with your\n",
"instructions to print everything (including the spaces) between the two\n",
"quotation marks."
"You should have seen a difference in the outputs for Sample 2. Python is\n",
"explicitly complying with your instructions to print everything (including the\n",
"spaces) between the two quotation marks.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Error Messages and Writing Code"
"### Error Messages and Writing Code\n"
]
},
{
Expand All @@ -209,10 +209,10 @@
"code. The error messages provide important information that helps you fix\n",
"problems.\n",
"\n",
"An error in a computer program is commonly called a *bug*, and the term used to\n",
"describe fixing those errors is *debugging*. [(why are coding errors called\n",
"An error in a computer program is commonly called a _bug_, and the term used to\n",
"describe fixing those errors is _debugging_. [(why are coding errors called\n",
"bugs?)](https://en.wikipedia.org/wiki/Software_bug) Below is a simple program\n",
"that has a bug. Run the code and observe the resulting error message."
"that has a bug. Run the code and observe the resulting error message.\n"
]
},
{
Expand All @@ -232,19 +232,19 @@
"The problem with the code above is that line 1 is missing a matching quotation\n",
"mark after the exclamation point. Is that what the error message said?\n",
"\n",
"It would be great if Python always told you *exactly* what was wrong with your\n",
"program. Python will get you close, usually telling you *something* went wrong,\n",
"but sometimes it's imprecise about exactly *where the problem is* and *what*\n",
"It would be great if Python always told you _exactly_ what was wrong with your\n",
"program. Python will get you close, usually telling you _something_ went wrong,\n",
"but sometimes it's imprecise about exactly _where the problem is_ and _what_\n",
"went wrong. This is not unique to Python; all programming languages \"do their\n",
"best\" to show you where errors are.\n",
"\n",
"When you write a computer program you should follow this design philosophy:\n",
"***build a little; test a little***. Focus on a specific capability, get it\n",
"working well, then move on to the next capability in your program. Begin by\n",
"sketching your thoughts on paper with flowcharts and diagrams. Software\n",
"engineers would refer to this as *Modular Design*. Don't approach a massive\n",
"programming task by just typing-away. Organize your thoughts first, asking\n",
"questions like:\n",
"**_build a little; test a little; learn a lot_**. Focus on a specific\n",
"capability, get it working well, then move on to the next capability in your\n",
"program. Begin by sketching your thoughts on paper with flowcharts and\n",
"diagrams. Software engineers would refer to this as _Modular Design_. Don't\n",
"approach a massive programming task by just typing-away. Organize your thoughts\n",
"first, asking questions like:\n",
"\n",
"- What is this program supposed to do?\n",
"- What are my inputs and outputs?\n",
Expand All @@ -254,12 +254,12 @@
"\n",
"Learning to program a computer is a hands-on activity. To get better at writing\n",
"computer programs, there simply is no substitute for having your hands on the\n",
"keyboard. As you get more practice you'll get better at it. It takes time and\n",
"patience. Programming a computer is very similar to learning to speak a new\n",
"language or learning how to play an instrument - the more you do it, the better\n",
"you get.\n",
"keyboard. As you get more practice you'll get better at it, but it takes time\n",
"and patience. Programming a computer is very similar to learning to speak a new\n",
"language or learning how to play a musical instrument - the more you do it, the\n",
"better you get.\n",
"\n",
"Oh yes, and don't forget to embrace your error messages!"
"Oh yes, and don't forget to embrace your error messages!\n"
]
},
{
Expand All @@ -268,25 +268,22 @@
"source": [
"### A Final Word About Python Reference Documentation\n",
"\n",
"The reference documentation for Python is ***outstanding***! You can find it at\n",
"The reference documentation for Python is **_outstanding_**! You can find it at\n",
"[https://www.python.org/](https://www.python.org/). I strongly recommend\n",
"bookmarking that site. Once you're there, you can get the documentation by\n",
"mousing over `Documentation` then clicking on `Python Docs` (see first picture\n",
"below). The next page will default to the documentation for the latest version\n",
"of Python. For this class, we're using Python 3.8.x, which you can access by\n",
"clicking on the appropriate link (see second picture below).\n",
"mousing over `Documentation` then clicking on `Python Docs` (see the picture\n",
"below). The next page will default to the documentation for the very latest\n",
"version of Python. For this class, we're using Python 3.10.x, which you can\n",
"access by clicking on the appropriate link on the left side of the page once\n",
"you open the documentation.\n",
"\n",
"Throughout these notebooks I'll often provide links directly into the\n",
"documentation, because the Python developers do such a great job of explaining\n",
"things. \n",
"things.\n",
"\n",
"<br clear=\"all\" />\n",
"<img src=\"../images/00documentation-00.png\" align=\"left\" />\n",
"<br clear=\"all\" />\n",
"\n",
"<br clear=\"all\" />\n",
"<img src=\"../images/00documentation-01.png\" align=\"left\" />\n",
"<br clear=\"all\" />"
"<br clear=\"all\" />\n"
]
},
{
Expand All @@ -301,14 +298,14 @@
"[Python Resources for Beginners](https://wiki.python.org/moin/BeginnersGuide)\n",
"\n",
"[Python Introduction\n",
"(w3schools)](https://www.w3schools.com/python/python_intro.asp)"
"(w3schools)](https://www.w3schools.com/python/python_intro.asp)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----\n",
"---\n",
"\n",
"MIT License\n",
"\n",
Expand Down Expand Up @@ -338,7 +335,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.10.6 64-bit",
"language": "python",
"name": "python3"
},
Expand All @@ -352,7 +349,12 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.10.6"
},
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 420ddd7

Please sign in to comment.