Skip to content

Commit

Permalink
Add Notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
nitya committed Nov 30, 2023
1 parent 796e9af commit 1a00327
Show file tree
Hide file tree
Showing 4 changed files with 257 additions and 29 deletions.
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
// Default codespaces-jupyter configuration
// See: https://github.com/github/codespaces-jupyter

"image": "mcr.microsoft.com/devcontainers/universal:2",
"hostRequirements": {
"cpus": 4
},
"waitFor": "onCreateCommand",
"updateContentCommand": "python3 -m pip install -r requirements.txt",
"postCreateCommand": "",
// "postCreateCommand": "cd docs && npm install && npm run dev",
"customizations": {
"codespaces": {
"openFiles": []
},
"vscode": {
"extensions": [
"ms-toolsai.jupyter",
"ms-python.python"
]
}
}
}
29 changes: 0 additions & 29 deletions docs/src/content/docs/01-basics/basics-01.ipynb

This file was deleted.

232 changes: 232 additions & 0 deletions notebooks/basics-01.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1. [Python Basics](https://www.coursera.org/learn/python-basics?specialization=python-3-programming)\n",
"\n",
"This is the first course in the 5-course specialization on _Python 3 Programming_ from the University Of Michigan. \n",
"It consists of 4 weeks of content:\n",
" 1. Welcome to Python Basics\n",
" 2. Programming in Python\n",
" 3. Turtle Graphics\n",
" 4. The Way of the Programmer\n",
"\n",
"## Runestone Platform\n",
"\n",
"The course uses the [Runestone Academy](https://landing.runestone.academy/computer-science-textbooks.html) platform which provides 3 resources in context:\n",
"1. The [Foundations Of Python Programming](https://runestone.academy/ns/books/published/fopp/index.html?mode=browsing) textbook by Prof. Paul Resnick (instructor for this course)\n",
"2. The [activecode](https://runestone.academy/ns/books/published/overview/ActiveCode/python.html?mode=browsing) interactive notebook with integrated time-travel (code versioning) \n",
"3. The [Python Tutor](https://pythontutor.com/)-based \"Code Lens\" feature for visual under-the-hood exploration.\n",
"3. Additional resources like [Problem Solving with Algorithms and Data Structures using Python](https://runestone.academy/ns/books/published/pythonds3/index.html?mode=browsing) for future study.\n",
"\n",
"## Study Objectives\n",
"\n",
"I have 3 objectives for this project:\n",
" 1. Learn Python3 programming from fundamentals to functional apps (data science, AI)\n",
" 2. Learn to use Jupyter Notebooks for interactive learning (instead of activecode)\n",
" 3. Capture study notes as a reusable reference that I can refactor/extend over time\n",
"\n",
"While I plan to capture notes and explore problems and exercises from the lectures within Jupyter Notebooks, I will **NOT** be documenting any assignments or solutions from either Coursera or Runestone sources, in keeping with the Honor Code. _If you find any such materials referenced, please file an issue via the repo so I can remove them_."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Week 1: Welcome to Python Basics\n",
"\n",
"Things covered in this week:\n",
" - What is the interactive textbook and Runestone platform (activecode)\n",
" - How programming languages (computers) differ from \"natural language\" (humans)\n",
" - Python is an interpreted language (vs. compiled)\n",
" - Exercise 1: Write the \"Hello World\" program"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Exercise 1: Print \"Hello World!\" to the screen\n",
"# Things Learned:\n",
"# using print() to print to the screen\n",
"# using comments to describe code\n",
"# note lack of semicolons to terminate statements\n",
"\n",
"print(\"Hello World!\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Week 2: Programming in Python\n",
"\n",
"Topics covered this week:\n",
" - [Values and Data Types](https://fopp.umsi.education/books/published/fopp/SimplePythonData/Values.html)\n",
" - [Operators and Operands](https://fopp.umsi.education/books/published/fopp/SimplePythonData/Operators.html)\n",
" - Oder of Operations\n",
" - Function Calls\n",
" - Data Types\n",
" - Type Conversion Functions\n",
" - Variables, Variable Names and Keywords\n",
" - Reassignment\n",
" - Statements and Expressions\n",
" - Updating Variables\n",
" - Hard-Coding\n",
" - Input\n",
" - (First Assessment)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# A Python statement is a line of code that the Python interpreter can execute \n",
"# A Python expression is a statement that evaluates to a value\n",
"# The simplest expression is a literal value (e.g. 100, \"Hello World!\", 3.14)\n",
"# Complex expressions are formed by combining simpler expressions with operators or function calls\n",
"# ---\n",
"# This is a simple expression. Running it will print the expression value to the screen\n",
"100"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# A value is a fundamental unit of data that the Python interpreter manipulates\n",
"# Values can be literals (e.g. 100, \"Hello World!\", 3.14) or variables (e.g. x, y, z)\n",
"# Values have data types (e.g. int, str, float)\n",
"# ---\n",
"# A variable is a name that refers to a value\n",
"# Variables are assigned values using the \"=\" operator\n",
"# These are examples of variable assignment statements\n",
"a = 100\n",
"b = 100.4\n",
"c = \"Hello World!\"\n",
"d = True\n",
"\n",
"# Fucntions are a type of statement that perform a specific task\n",
"# Functions are called by name, can take 0 or more arguments, and can return a value\n",
"# ---\n",
"# The print() function prints the value of the expression to output\n",
"# The type() function returns the data type of the value\n",
"print(a, \"is of type\", type(a))\n",
"print(b, \"is of type\", type(b))\n",
"print(c, \"is of type\", type(c))\n",
"print(d, \"is of type\", type(d))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Operators allow you to combine expressions to form more complex expressions\n",
"# Examples of operators are +, -, *, /, and %\n",
"# Operands are the values that operators act on\n",
"# ---\n",
"# Here are some examples of mathematical operators\n",
"print(\"100 + 200 =\", 100 + 200)\n",
"print(\"100 - 200 =\", 100 - 200)\n",
"print(\"100 * 200 =\", 100 * 200)\n",
"print(\"100 / 200 =\", 100 / 200)\n",
"print(\"100 % 200 =\", 100 % 200)\n",
"\n",
"# The + operator can also be used to concatenate strings\n",
"print(\"Hello\" + \" \" + \"World!\")\n",
"\n",
"# The * operator can also be used to repeat strings\n",
"print(\"Hello \" * 3)\n",
"\n",
"# The / operator can also be used to perform floor division\n",
"print(\"100 // 200 =\", 100 // 200)\n",
"\n",
"# The ** operator can also be used to perform exponentiation\n",
"print(\"2 ** 3 =\", 2 ** 3)\n",
"\n",
"# The = operator can also be used to assign values to multiple variables\n",
"a = b = c = 100\n",
"print(\"Assign value to multiple variables\", a, b, c)\n",
"\n",
"# The += operator can also be used to increment a variable\n",
"a = 100\n",
"a += 1\n",
"print(\"Increment a variable\", a)\n",
"\n",
"# The % operator can also be used to find the remainder of a division\n",
"a = 100\n",
"a %= 3\n",
"print(\"Find remainder of division\", a)\n",
"\n",
"# The -= operator can also be used to decrement a variable\n",
"a = 100\n",
"a -= 1\n",
"print(\"Decrement a variable\", a)\n",
"\n",
"# The *= operator can also be used to multiply a variable\n",
"a = 100\n",
"a *= 2\n",
"print(\"Multiply a variable\", a)\n",
"\n",
"# The /= operator can also be used to divide a variable\n",
"a = 100\n",
"a /= 2\n",
"print(\"Divide a variable\", a)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Week 3: Turtle Graphics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Week 4: The Way of the Programmer"
]
}
],
"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.10.8"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ipywidgets

0 comments on commit 1a00327

Please sign in to comment.