Skip to content

Commit

Permalink
Snapshot Update -- Lots of changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
geozeke committed May 24, 2020
1 parent 589a8c2 commit 0faae61
Show file tree
Hide file tree
Showing 33 changed files with 2,882 additions and 85 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# Introduction to Python using Jupyter Notebooks
# Introduction to Python Using Jupyter Notebooks

This is a collection of Jupyter Notebooks for teaching Python programming with an emphasis on the fundamentals of Cyber Operations. It's not meant to be a complete Python textbook, but rather an organized reference guide to allow you to see interactive examples on specific Python topics.

## Topics

0. Introduction
1. Introduction
* Using Jupyter notebooks
* Your First Python Program


1. Basic operations
2. Basic operations
* Variables, Assignment Statements, Expressions
* Reading console input
* Numeric Data Types
* Operator Precedence
* Strings
* Type Conversions and Rounding
* Type Conversions


2. Functions and Objects
3. Built-in Functions and Objects
* Common Functions
* Object and Methods
* Formatting output (`.format()`)
* Objects and Methods
* Formatting output with `.format()`


3. Branch Logic
4. Branch Logic
* Boolean Data Types
* `if` Statements
* `if` - `else` Statements
Expand All @@ -33,50 +33,50 @@ This is a collection of Jupyter Notebooks for teaching Python programming with a
* Operator Precedence


4. Iteration (Loops)
5. Iteration (Loops)
* `for` Loop
* `while` Loop
* Nested Loops
* `break` and `continue`


5. Functions
6. User Defined Functions
* Introduction
* Defining Functions
* Calling Functions
* Arguments and Parameters
* Pass by Reference
* Variable Scope
* Returning Multiple Values


6. Lists, Dictionaries, Sets, Tuples
7. Collections: Lists, Dictionaries, Sets, Tuples
* Creating
* Accessing Data
* Functions - Pass by Reference
* Functions - Returning Multiple Values


7. File I/O
8. File I/O
* Modes: read (`'r'`), write (`'w'`), append(`'a'`)
* Ways to Read: `read()`, `readline()`, `readlines()`
* Writing and Closing: `write()`, `close()`


8. Crypto
9. Crypto
* Hashing Strings


9. Exception Handling
10. Exception Handling
* Catching exceptions
* Raising exceptions


10. Recursion
11. Recursion
* Introduction
* Examples


11. OOP
12. OOP
* User-defined Classes


12. Misc Topics
13. Misc Topics
132 changes: 132 additions & 0 deletions content/00_tableOfContents.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Table Of Contents\n",
"\n",
"This is a collection of Jupyter Notebooks for teaching Python programming with an emphasis on the fundamentals of Cyber Operations. It's not meant to be a complete Python textbook, but rather an organized reference guide to allow you to see interactive examples on specific Python topics.\n",
"\n",
"## Topics\n",
"\n",
"1. Introduction\n",
" * Using Jupyter notebooks\n",
" * Your First Python Program\n",
" \n",
" \n",
"2. Basic operations\n",
" * Variables, Assignment Statements, Expressions\n",
" * Reading console input\n",
" * Numeric Data Types\n",
" * Operator Precedence\n",
" * Strings\n",
" * Type Conversions\n",
" \n",
" \n",
"3. Functions and Objects\n",
" * Common Functions\n",
" * Objects and Methods\n",
" * Formatting output with `.format()`\n",
" \n",
" \n",
"4. Branch Logic\n",
" * Boolean Data Types\n",
" * `if` Statements\n",
" * `if` - `else` Statements\n",
" * `if` - `elif` - `else` Statements\n",
" * Logical operators (`and`, `or`, `not`)\n",
" * Operator Precedence\n",
" \n",
" \n",
"5. Iteration (Loops)\n",
" * `for` Loop\n",
" * `while` Loop\n",
" * Nested Loops\n",
" * `break` and `continue`\n",
" \n",
"\n",
"6. Functions\n",
" * Introduction\n",
" * Defining Functions\n",
" * Calling Functions\n",
" * Arguments and Parameters\n",
" * Pass by Reference\n",
" * Variable Scope\n",
" * Returning Multiple Values\n",
" \n",
" \n",
"7. Collections: Lists, Dictionaries, Sets, Tuples\n",
" * Creating\n",
" * Accessing Data\n",
"\n",
" \n",
"8. File I/O\n",
" * Modes: read (`'r'`), write (`'w'`), append(`'a'`)\n",
" * Ways to Read: `read()`, `readline()`, `readlines()`\n",
" * Writing and Closing: `write()`, `close()`\n",
" \n",
"\n",
"9. Crypto\n",
" * Hashing Strings\n",
"\n",
"\n",
"10. Exception Handling\n",
" * Catching exceptions\n",
" * Raising exceptions\n",
"\n",
"\n",
"11. Recursion\n",
" * Introduction\n",
" * Examples\n",
"\n",
"\n",
"12. OOP\n",
" * User-defined Classes\n",
"\n",
"\n",
"13. Misc Topics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n",
"\n",
"*MIT License*\n",
"\n",
"*Copyright 2019-2020 Peter Nardi*\n",
"\n",
"*Terms of use:*\n",
"\n",
"*Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:*\n",
"\n",
"*The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.*\n",
"\n",
"*THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
57 changes: 46 additions & 11 deletions content/00_intro00.ipynb → content/01_intro00.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Code Examples\n",
"### Code Examples\n",
"Here are some examples of executable Python3 code blocks that you'll see in Jupyter Notebooks."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To run the code below, click (once) on the code block and press `Cntl-Enter`.\n",
"\n",
"This code example is interactive and will ask you for input.\n",
"\n",
"To re-run the code, press `Cntl-Enter` again.\n",
"\n",
"To clear the output, right-click on the cell and select `Clear Outputs`"
"- To run the code below, click (once) on the code block, hold the `Control` key and press the `Enter` key (`Cntl-Enter`).\n",
"- This code example is interactive and will ask you for input.\n",
"- To re-run the code, press `Cntl-Enter` again.\n",
"- To clear the output, right-click on the cell and select `Clear Outputs`"
]
},
{
Expand Down Expand Up @@ -88,16 +85,54 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, here's a simple \"Magic 8-Ball\" game. Credit for idea to: [Python for Beginners](https://www.pythonforbeginners.com/code-snippets-source-code/magic-8-ball-written-in-python/)"
"### If Code Cells Won't Clear or Run\n",
"\n",
"Occasionally jupyter lab will appear to \"hang\" when running a code cell. This is often because some code in the backround is waiting for input or is dealing with an error condition. Take the example below, which prints `Hello`, then goes into a loop that runs forever (what's called an [infinite loop](https://en.wikipedia.org/wiki/Infinite_loop)). As a result, `Goodbye` never prints to the screen and jupyter lab appears to be unresponsive; no other code cells will run.\n",
"\n",
"Try running the code cell below. You should see `Hello` print to the screen, then nothing. Clear the cell and try to run it again. Notice that nothing happens. You'll know that the cell is unresponsive because you'll see an asterisk next to the top of the cell. If that happens, just press the *Interrupt the kernel* button (small square at the top of the window) to reset it."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"Hello\")\n",
"while(1):\n",
" x = 1\n",
"print(\"Goodbye\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br clear=\"all\" />\n",
"<img src=\"../images/00restartkernel.png\" align=\"left\" />\n",
"<br clear=\"all\" />"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### If You Accidently Double-click a Text Cell\n",
"\n",
"Don't worry :-)\n",
"\n",
"If you double-click a text cell you put it in *edit mode*. Text cells are written in a language called [markdown](https://www.markdownguide.org/getting-started/) and double-clicking on one allows you to edit the underlying content. If you accidently double-click on one, just \"run\" the cell like you would a code cell (holding the `Control` key and pressing the `Enter` key). This will put it back into *display mode*. Go ahead and try it. Double-click this cell to enter *edit mode*, then press `Control-Enter` to put it back into *display mode*.\n",
"\n",
"You shouldn't have a need to manipulate text cells in these notebooks, but if you put one in *edit mode* by mistake, now you know how to put it back into *display mode*."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Closing jupyter lab\n",
"### Closing jupyter lab\n",
"\n",
"When you're done using jupyter lab, the easiest way to exit is to select \"Shutdown\" from the File menu in the browser. You can then close the browser window where it's running (saving any changes to your notebooks if desired).\n",
"When you're done using jupyter lab, the easiest way to exit is to select \"Shutdown\" from the File menu in the browser. You can then close the browser, saving any changes to your notebooks if desired.\n",
"\n",
"<br clear=\"all\" />\n",
"<img src=\"../images/00shutdown.png\" align=\"left\" />\n",
Expand Down
6 changes: 3 additions & 3 deletions content/00_intro01.ipynb → content/01_intro01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"It's your turn. Modify the program above to print the sum of the first 10 even integers (starting from 2). When you ran the program did you get 110?"
"It's your turn. Modify the program above to print the sum of the first 10 even integers (starting from 2). When you run your updated program do you get 110?"
]
},
{
Expand Down Expand Up @@ -103,7 +103,7 @@
"source": [
"### Speaking of Spaces\n",
"\n",
"If you can put blank lines (spaces) between blocks of code, what about spaces within a single line of code?\n",
"If you can put blanks (spaces) between lines of code, what about spaces within a single line of code?\n",
"\n",
"Python is quite forgiving about how things are spaced-out. If often comes down to readability. Can you (or your instructor) easily read your code and follow along? While the program may run just fine, be mindful that you can change the intended result because of the particular spacing you used.\n",
"\n",
Expand Down Expand Up @@ -212,7 +212,7 @@
"source": [
"### A Final Word About Python Reference Documentation\n",
"\n",
"The reference document for Python is ***outstanding***! You can find it at [https://www.python.org/](https://www.python.org/). I strongly recommend bookmarking that site. Once you're there, you can get the latest documentation by clicking on `Documentation` then `Python 3.x Docs` (see picture below). Throughout these notebooks I'll often provide links directly into the documentation, because the Python developers do such a great job of explaining things. \n",
"The reference documentation for Python is ***outstanding***! You can find it at [https://www.python.org/](https://www.python.org/). I strongly recommend bookmarking that site. Once you're there, you can get the latest documentation by clicking on `Documentation` then `Python 3.x Docs` (see picture below). Throughout these notebooks I'll often provide links directly into the documentation, because the Python developers do such a great job of explaining things. \n",
"\n",
"<br clear=\"all\" />\n",
"<img src=\"../images/00documentation.png\" align=\"left\" />\n",
Expand Down
Loading

0 comments on commit 0faae61

Please sign in to comment.