diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 000000000..e983f32fe
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,19 @@
+name: YouTube Videos
+
+on:
+ schedule:
+ # Runs every day at noon
+ - cron: '0 12 * * *'
+ workflow_dispatch:
+
+jobs:
+ update-readme-with-youtube:
+ name: Update this repo's README with latest videos from YouTube
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: gautamkrishnar/blog-post-workflow@c379ef323a0d32800e511926874d893976e400cc
+ with:
+ comment_tag_name: "YOUTUBE-VIDEOS-LIST"
+ feed_list: "https://www.youtube.com/feeds/videos.xml?channel_id=UCNDfiL0D1LUeKWAkRE1xO5Q"
+ max_post_count: 7
diff --git a/Makefile b/Makefile
index f128614d5..0dc625638 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,6 @@ test:
lint:
pylint --disable=R,C,W1202 \
- src/chap14/flask-sklearn/*.py \
-
+ src/chap14-MLOps/flask-sklearn/*.py
all: install lint test
diff --git a/README.md b/README.md
index 5bc5482e4..cd361a338 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,19 @@
+## π Pragmatic AI Labs | Join 1M+ ML Engineers
+
+### π₯ Hot Course Offers:
+* π€ [Master GenAI Engineering](https://ds500.paiml.com/learn/course/0bbb5/) - Build Production AI Systems
+* π¦ [Learn Professional Rust](https://ds500.paiml.com/learn/course/g6u1k/) - Industry-Grade Development
+* π [AWS AI & Analytics](https://ds500.paiml.com/learn/course/31si1/) - Scale Your ML in Cloud
+* β‘ [Production GenAI on AWS](https://ds500.paiml.com/learn/course/ehks1/) - Deploy at Enterprise Scale
+* π οΈ [Rust DevOps Mastery](https://ds500.paiml.com/learn/course/ex8eu/) - Automate Everything
+
+### π Level Up Your Career:
+* πΌ [Production ML Program](https://paiml.com) - Complete MLOps & Cloud Mastery
+* π― [Start Learning Now](https://ds500.paiml.com) - Fast-Track Your ML Career
+* π’ Trusted by Fortune 500 Teams
+
+Learn end-to-end ML engineering from industry veterans at [PAIML.COM](https://paiml.com)
+
# Python For DevOps: Learn Ruthlessly Effective Automation
#### Publisher: [O'Reilly Media](http://shop.oreilly.com/product/0636920274902.do)
#### Release Date: December 31st, 2019
@@ -28,40 +44,42 @@ Building, deploying, and operationalizing a machine learning project
## Book Outline
-1. Python Essentials for DevOps
-2. Automating Files and the Filesystem
-3. Working with the Command Line
+### Chapter 1: Python Essentials for DevOps
+### Chapter 2: Automating Files and the Filesystem
+### Chapter 3: Working with the Command Line
* [Source Case Study](https://github.com/noahgift/nuclear_powered_command_line_tools)
-* [Notes](notes/chap3.md)
+* [GPU Programming Colab Notebook](https://github.com/noahgift/cloud-data-analysis-at-scale/blob/master/GPU_Programming.ipynb)
+* [Notes](https://paiml.github.io/python_devops_book/notes/chap3)
-4. Useful Linux Utilities
-5. Package Management
-6. Continuous Integration and Continuous Deployment
+### Chapter 4: Useful Linux Utilities
+### Chapter 5: Package Management
+### Chapter 6: Continuous Integration and Continuous Deployment
* [Source](https://github.com/noahgift/hugotools)
+* [Notes](https://paiml.github.io/python_devops_book/notes/chap6)
-7. Monitoring and Logging
-8. Pytest for DevOps
-9. Cloud Computing
+### Chapter 7: Monitoring and Logging
+### Chapter 8: Pytest for DevOps
+### Chapter 9: Cloud Computing
* [Source](https://github.com/paiml/python_devops_book/tree/master/src/chap9)
-* [Notes](notes/chap9.md)
+* [Notes](https://paiml.github.io/python_devops_book/notes/chap9)
-10. Infrastructure as Code
-11. Container Technologies: Docker and Docker Compose
-12. Container Orchestration: Kubernetes
-13. Serverless Technologies
-14. MLOps and Machine learning Engineering
+### Chapter 10: Infrastructure as Code
+### Chapter 11: Container Technologies: Docker and Docker Compose
+### Chapter 12: Container Orchestration: Kubernetes
+### Chapter 13: Serverless Technologies
+### Chapter 14: MLOps and Machine learning Engineering
* [Source](https://github.com/paiml/python_devops_book/tree/master/src/chap14)
-* [Notes](notes/chap14.md)
+* [Notes](https://paiml.github.io/python_devops_book/notes/chap14)
-15. Data Engineering
+### Chapter 15: Data Engineering
* [Source](https://github.com/noahgift/awslambda)
-16. DevOps War Stories and Interviews
+### Chapter 16: DevOps War Stories and Interviews
## Got Feedback?
@@ -71,13 +89,13 @@ If you have any suggestions as the book is being developed please [create a tick
A list of Frequently Asked Questions about the book:
-* [FAQ](https://github.com/paiml/python_devops_book/blob/master/docs/faq.md)
+* [FAQ](https://paiml.github.io/python_devops_book/docs/faq)
## Addendum
Updates on new material post book release.
-* [Addendum](https://github.com/paiml/python_devops_book/blob/master/docs/addendum.md)
+* [Addendum](https://paiml.github.io/python_devops_book/docs/addendum.md)
## Contact Authors
@@ -89,6 +107,22 @@ Updates on new material post book release.
* [Read other books by Noah Gift](https://www.noahgift.com/books/latest/)
* [Take courses by Noah Gift](https://www.noahgift.com/courses/latest/)
* [Watch Videos by Noah Gift](https://www.noahgift.com/videos/latest/)
+* [Take the Foundations of Data Engineering Specialization](https://www.coursera.org/specializations/python-bash-sql-data-engineering-duke)
+* [Take the Specialization: Building Cloud Computing Solutions at Scale Specialization](https://www.coursera.org/learn/cloud-computing-foundations-duke?specialization=building-cloud-computing-solutions-at-scale)
+
+#### πΊ Latest YouTube Videos
+
+
+
+
+- [APR Chat Demo](https://www.youtube.com/watch?v=BEsKT-dcbeE)
+- [Building Live Pong Game with Embedded .APR Models π±](https://www.youtube.com/watch?v=Nv32meSHuQo)
+- [Building Live Pong Game with Embedded .APR Models](https://www.youtube.com/watch?v=MoQ-kiOm57Q)
+- [ELO Ratings Questions](https://www.youtube.com/watch?v=7hkQH_gdZuw)
+- [The 2X Ceiling: Why 100 AI Agents Can't Outcode Amdahl's Law"](https://www.youtube.com/watch?v=_0WwSvUjYZw)
+- [Rust Fundamentals COURSE PREVIEW - Basic components of RUST code](https://www.youtube.com/watch?v=25AKa3ogpT8)
+- [Applied GitHub Platform COURSE PREVIEW - Continuous Delivery Project Overview](https://www.youtube.com/watch?v=PouBuld9Uvo)
+
### Kennedy Behrman
@@ -101,3 +135,6 @@ Updates on new material post book release.
### Grig Gheorghiu
* [Grig Gheorghiu](https://www.linkedin.com/in/ggheorghiu/)
+
+* [β¨Pragmatic AI Labs builds courses on edX](https://insight.paiml.com/d69)
+* [ π¬ Join our Discord community](https://discord.gg/ZrjWxKay)
diff --git a/_config.yml b/_config.yml
new file mode 100644
index 000000000..2f7efbeab
--- /dev/null
+++ b/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-minimal
\ No newline at end of file
diff --git a/docs/addendum.md b/docs/addendum.md
index 64b259ea2..1c75f7d15 100644
--- a/docs/addendum.md
+++ b/docs/addendum.md
@@ -1 +1,3 @@
# Addendum
+
+Take a look at some of the [chapter notes](https://github.com/paiml/python_devops_book/tree/master/notes)
diff --git a/notes/chap6.md b/notes/chap6.md
index e69de29bb..11f225241 100644
--- a/notes/chap6.md
+++ b/notes/chap6.md
@@ -0,0 +1,6 @@
+## Chapter 6 NOTES
+
+[Noah](noahgift.com) is working on some additional content around continuous delivery for a course for Duke MIDS. Here is a tutorial for how to create a continuous delivery system using AWS Cloud9, AWS Code Build and Hugo:
+
+### [Hugo AWS Continuous Delivery from Zero](https://noahgift.github.io/cloud-data-analysis-at-scale/topics/continuous-delivery)
+[](https://youtu.be/xiodvLdPnvI)
diff --git a/notes/chap9.md b/notes/chap9.md
index e69de29bb..57b3620c5 100644
--- a/notes/chap9.md
+++ b/notes/chap9.md
@@ -0,0 +1,7 @@
+## Chapter 9 NOTES: Cloud Computing
+
+Some additional topics you may enjoy:
+
+* [Cloud Onboarding](https://noahgift.github.io/cloud-data-analysis-at-scale/topics/cloud-onboarding)
+* [Cloud Service Model](https://noahgift.github.io/cloud-data-analysis-at-scale/topics/cloud-service-model)
+* [IaC](https://noahgift.github.io/cloud-data-analysis-at-scale/topics/iac)
diff --git a/src/chap01-EssentialPython/Chapter_1_Python_Essentials_For_Devops.ipynb b/src/chap01-EssentialPython/Chapter_1_Python_Essentials_For_Devops.ipynb
new file mode 100644
index 000000000..7a65c0fe5
--- /dev/null
+++ b/src/chap01-EssentialPython/Chapter_1_Python_Essentials_For_Devops.ipynb
@@ -0,0 +1,3248 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "name": "Chapter.1.Python.Essentials.For.Devops.ipynb",
+ "provenance": [],
+ "authorship_tag": "ABX9TyNhkZWchN2BGgEaRy3/fCeK",
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "# Python Essentials For Devops"
+ ],
+ "metadata": {
+ "id": "YW34gzHbOdBg"
+ }
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Procedural Programming"
+ ],
+ "metadata": {
+ "id": "zfknyVDHOxc0"
+ }
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "suvTFE2lOURS",
+ "outputId": "638d787e-679f-43b8-fdb2-174cd1c25633"
+ },
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "3"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
+ "source": [
+ "i = 1\n",
+ "j = i +1\n",
+ "i + j"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Variables"
+ ],
+ "metadata": {
+ "id": "Nk2682XGO_nI"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "dog_name = 'spot'\n",
+ "dog_name"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "Kq80DMnJOkEn",
+ "outputId": "edc62276-b84e-4c33-e50d-c44cc4ab60ab"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'spot'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 2
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "dog_name = 'rex'\n",
+ "dog_name"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "wNnBaKd9PF0q",
+ "outputId": "4f3399f9-6d8d-4160-fb98-ac4c55312300"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'rex'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 3
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "dog_name = 't-' + dog_name\n",
+ "dog_name"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "MmaVNF2PPItS",
+ "outputId": "7572214a-f081-401a-9ee1-6767c81baa01"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'t-rex'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 4
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "big = 'large'\n",
+ "big"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "PXrtHv5kPOW5",
+ "outputId": "17bb4de9-1a2a-406f-aa63-5010ce19a68f"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'large'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 5
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "big = 1000*1000\n",
+ "big"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "jITOtC6XPSXB",
+ "outputId": "293481f3-aeb0-4f8b-df93-916eb22db973"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "1000000"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 6
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "big = {}\n",
+ "big"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "P2OQQ5ABPVf5",
+ "outputId": "ef96986c-ec75-49cc-9f4f-b44ff494004c"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "{}"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 7
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Basic Math"
+ ],
+ "metadata": {
+ "id": "J5GiE2RFPeee"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "1 + 1"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "UStdn-M6PXsQ",
+ "outputId": "3e8e3f92-6564-4505-cd45-df435d4a55bd"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "2"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 8
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "3 - 4 "
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "NwvtX22VPix3",
+ "outputId": "41421719-f0ef-4886-9dd6-f8a8273f4106"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "-1"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 9
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "2*5"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "rLtfGZp5PlF3",
+ "outputId": "313b43c7-0e31-48bc-d1ca-e90dcfaab9cc"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "10"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 10
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "2/3"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "sKdXaOmZPm3v",
+ "outputId": "e1c531cc-57c3-414f-c587-f45c9f7b1100"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "0.6666666666666666"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 11
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "5/2"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "C2o1Lk1aPobe",
+ "outputId": "9f4d85d6-0237-4cad-f708-e503d895a78f"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "2.5"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 12
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "5//2"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "HjnZkMskPphe",
+ "outputId": "cd0d7dc1-19e0-433a-b6d2-bf431b96ef60"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "2"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 13
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "3**2"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "utxmDVHZPq1e",
+ "outputId": "649062e9-cc6f-4ab2-d021-a51bee79b19a"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "9"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 14
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "5%2"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "cdqy2pvVPsFW",
+ "outputId": "4b6b97c0-d0dc-4ff7-d927-ab46078a9a1b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "1"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 15
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Comments"
+ ],
+ "metadata": {
+ "id": "3oYZHcGZPvT0"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# This is a comment"
+ ],
+ "metadata": {
+ "id": "egBeBtHvPuVm"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "1 + 1 # This comment follows a statement"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "SHp7IGS9P0Uu",
+ "outputId": "6df9a853-0dda-44e9-a3c3-995e92052c8b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "2"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 17
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "\"\"\"\n",
+ "This statement is a block comment.\n",
+ "It can run for multiple lines\n",
+ "\"\"\""
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "Wat04mnqP4Ht",
+ "outputId": "4585f5e0-c5b7-4981-8da9-45d2b7956b93"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'\\nThis statement is a block comment.\\nIt can run for multiple lines\\n'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 18
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'''This statement is also a block comment'''"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "9cPgU5EZRDfm",
+ "outputId": "55504659-3a64-432c-fd8a-7a7d0ce53e03"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'This statement is also a block comment'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 19
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Built-in Functions"
+ ],
+ "metadata": {
+ "id": "gOriPf-PRMS9"
+ }
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### Print"
+ ],
+ "metadata": {
+ "id": "WZodQRGVRmj4"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# This is my first Python script\n",
+ "print(\"Hello world!\")"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "fxx5W83hRIib",
+ "outputId": "319c8344-97b8-42fd-9779-c026a62e8e6c"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Hello world!\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### Range"
+ ],
+ "metadata": {
+ "id": "Ksb5DdpBR5yZ"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "range(10)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "frx_zC99Rxxz",
+ "outputId": "cc16664c-c878-4927-f7ea-5b18f15b651a"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "range(0, 10)"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 21
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "list(range(10))"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "RZKqx8pKR9UH",
+ "outputId": "ffc8e1dc-24cc-4ac1-d610-511d47afa98a"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 22
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "list(range(5, 10, 3)"
+ ],
+ "metadata": {
+ "id": "5kF5t7HZR_j4"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Execution Control"
+ ],
+ "metadata": {
+ "id": "AeV4KATpSFvO"
+ }
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### if/elif/else"
+ ],
+ "metadata": {
+ "id": "4Vauhe5PSJkO"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "i = 45\n",
+ "\n",
+ "if i ==45:\n",
+ " print('i is 45')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "5AGovrsISLrO",
+ "outputId": "09b9eabe-771c-4980-ea8a-003a284681df"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "i is 45\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "i = 35\n",
+ "\n",
+ "if i == 45:\n",
+ " print('i is 45')\n",
+ "elif i == 35:\n",
+ " print('i is 35')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "8Nh0rMqhSSUs",
+ "outputId": "ca41ab7b-ee0f-4c78-d690-a878d6f3c62b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "i is 35\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "i = 0\n",
+ "\n",
+ "if i == 45:\n",
+ " print('i is 45')\n",
+ "elif i == 35:\n",
+ " print('i is 35')\n",
+ "elif i > 10:\n",
+ " print('i is greater than 10')\n",
+ "elif i%3 == 0:\n",
+ " print('i is a multiple of 3')\n",
+ "else:\n",
+ " print(\"I don't know much about i...\")"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "xLebgxMOST3N",
+ "outputId": "689efc90-e30b-4826-83df-be8e8238bbb6"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "i is a multiple of 3\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "cat = 'spot'\n",
+ "if 's' in cat:\n",
+ " print(\"Found an 's' in a cat\")\n",
+ " if cat == 'Sheba':\n",
+ " print(\"I found Sheba\")\n",
+ " else:\n",
+ " print(\"Some other cat\")\n",
+ "else:\n",
+ " print(\" a cat without 's'\")\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "uelNNotQSxXR",
+ "outputId": "c55a18f5-3cf0-441c-a9a9-75ae89b4ea92"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Found an 's' in a cat\n",
+ "Some other cat\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### for Loops"
+ ],
+ "metadata": {
+ "id": "i9nQRSDuUuuk"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "for i in range(10):\n",
+ " x = i*2\n",
+ " print(x)\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "De_y-2bYUtBE",
+ "outputId": "8ba04508-5f73-4be9-a274-b34a6af4a9b1"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "0\n",
+ "2\n",
+ "4\n",
+ "6\n",
+ "8\n",
+ "10\n",
+ "12\n",
+ "14\n",
+ "16\n",
+ "18\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "for i in range(6):\n",
+ " if i == 3:\n",
+ " continue\n",
+ " print(i)\n"
+ ],
+ "metadata": {
+ "id": "7H4sa-wsVrV6"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### while Loops"
+ ],
+ "metadata": {
+ "id": "ogEkJV8FVzcZ"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "count = 0\n",
+ "while count < 3:\n",
+ " print(f\"The count is {count}\")\n",
+ " count += 1\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "Bfw1qL5xV0_o",
+ "outputId": "a090d8a9-792f-49f4-c2fd-8bd4891c1b96"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "The count is 0\n",
+ "The count is 1\n",
+ "The count is 2\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "count = 0\n",
+ "while True:\n",
+ " print(f\"The count is {count}\")\n",
+ " if count > 5:\n",
+ " break\n",
+ " count += 1\n"
+ ],
+ "metadata": {
+ "id": "9pJb-W_tV5ge"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### Handling Exceptions"
+ ],
+ "metadata": {
+ "id": "_bkzjadcWGns"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "thinkers = ['Plato', 'PlayDo', 'Gumby']\n",
+ "while True:\n",
+ " try:\n",
+ " thinker = thinkers.pop()\n",
+ " print(thinker)\n",
+ " except IndexError as e:\n",
+ " print(\"We tried to pop too many thinkers\")\n",
+ " print(e)\n",
+ " break\n"
+ ],
+ "metadata": {
+ "id": "cqz2_-tEWI29"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Built-in Objects"
+ ],
+ "metadata": {
+ "id": "Bv0NroRXWPZ7"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# Define a class for fancy defining fancy cars\n",
+ "class FancyCar():\n",
+ " pass\n"
+ ],
+ "metadata": {
+ "id": "WELPPfm2WTiL"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# Define a class for fancy defining fancy cars\n",
+ "class FancyCar():\n",
+ " pass"
+ ],
+ "metadata": {
+ "id": "FwLEsD9IWh6P"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "type(FancyCar)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "Ss_q00r-Wl_g",
+ "outputId": "e8b693cb-a303-4c68-f519-03ba1966809e"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "type"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 35
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# Instantiate a fancy car\n",
+ "my_car = FancyCar()\n",
+ "type(my_car)"
+ ],
+ "metadata": {
+ "id": "iymktzZmWo04"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Object Methods and Attributes"
+ ],
+ "metadata": {
+ "id": "5L6x_7B3W3jD"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# Define a class for fancy defining fancy cars\n",
+ "class FancyCar():\n",
+ " # Add a class variable\n",
+ " wheels = 4\n",
+ " # Add a method\n",
+ " def driveFast(self):\n",
+ " print(\"Driving so fast\")\n",
+ " \n",
+ " \n",
+ " \n",
+ "# Instantiate a fancy car\n",
+ "my_car = FancyCar()\n",
+ "# Access the class attribute\n",
+ "my_car.wheels\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "-IUwdnxzW7WL",
+ "outputId": "f9e892ce-d8c7-4b45-f9ae-b4e34c456a5d"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "4"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 36
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# Invoke the method\n",
+ "my_car.driveFast()"
+ ],
+ "metadata": {
+ "id": "PNIyUdSPXOYI"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Sequences"
+ ],
+ "metadata": {
+ "id": "2plC-Ba-XarV"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "2 in [1,2,3]"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "inDbOAYAXeu1",
+ "outputId": "b83bbbaa-810d-4e73-82e9-3bb283729105"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 37
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'a' not in 'cat'"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "zZ-ZeyceXlWd",
+ "outputId": "7253ec6d-4b8a-4bbf-ad84-7bda3be1bfa0"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "False"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 38
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "10 in range(12)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "idLCV71XXoYz",
+ "outputId": "60fefd82-f71e-44ab-f871-30e442a4cfb0"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 39
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "10 not in range(2, 4)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "1pBRig-EXrqD",
+ "outputId": "50dd5135-6a4e-444b-e2d7-354dbf5e323b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 40
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence = 'Bill Cheatham'\n",
+ "my_sequence[0]\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "_sEtToWqX0e8",
+ "outputId": "23284ad9-a460-4b3b-d0f8-82181c6de2b8"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'B'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 41
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence[2]"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "mZML90mVX4Gy",
+ "outputId": "f9f816b1-b383-4f42-fe8d-b297f79af631"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'l'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 42
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence[12]"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "ZwKUqCmjX8Pq",
+ "outputId": "b9542eb5-bc6d-491e-b478-7a84547a4abd"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'m'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 43
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence = \"Bill Cheatham\"\n",
+ "my_sequence[-1]\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "_H_IYfzxYD6J",
+ "outputId": "94569fb2-1913-4c8b-c99a-42080e2f8670"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'m'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 45
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence[-2]"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "s3j2a3Y9YHBq",
+ "outputId": "0d35614a-826f-408a-8a24-ebfddffee755"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'a'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 46
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence[-13]"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "MvhZCxayYQEv",
+ "outputId": "18793cc4-dbab-46ec-f463-64ff5c97ceca"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'B'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 47
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence.index('C')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "0M02DukOYSxY",
+ "outputId": "aabc7c92-4de8-4ec2-a44f-664a0ead4d3b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "5"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 48
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence.index('a')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "3DavDkZAYYmn",
+ "outputId": "5cd0cbad-277d-40cd-cc98-8bfce22d4aba"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "8"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 49
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence.index('a', 9, 12)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "hQ66iHooYbYv",
+ "outputId": "f082172a-5dce-4cd9-d4be-f3b315d641f9"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "11"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 50
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence[11]"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "NX6cQu-VYfZ2",
+ "outputId": "72a310cd-8990-44a0-f8ca-2992b3179cf0"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'a'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 51
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence = ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n",
+ "my_sequence[2:5]"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "WDUgkZkeYjjd",
+ "outputId": "a92e53c7-2fd5-4137-b3d7-8e23c1eade4b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['c', 'd', 'e']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 52
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence[:5]"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "Cm2D0eDFfKw3",
+ "outputId": "7ad51580-0974-49bc-deda-3c1be337b8be"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['a', 'b', 'c', 'd', 'e']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 53
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence[3:]"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "YXzBGCHIfRfO",
+ "outputId": "c60e0238-17d9-4273-98c3-0bf758e0fac9"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['d', 'e', 'f', 'g']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 54
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence[-6:]"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "GxzMW-3MfW7l",
+ "outputId": "e474ffe7-a69a-4c3f-c705-f8977a599f99"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['b', 'c', 'd', 'e', 'f', 'g']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 55
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence[3:-1]"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "_3XhBX_SfZY1",
+ "outputId": "82728342-eb8c-4609-d3f2-17ab8f5ba023"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['d', 'e', 'f']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 56
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence = [0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4]\n",
+ "len(my_sequence)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "kBJ-ErYvfd2V",
+ "outputId": "f387daa2-b06d-44f8-a626-effbb2ef7526"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "12"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 57
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "min(my_sequence)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "O62cx6yMfix9",
+ "outputId": "e35c7d61-1ee8-4e35-927e-a649a6982428"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "0"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 58
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "max(my_sequence)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "ATOCBaY3fmxM",
+ "outputId": "6b7d98fc-5cb5-40b6-da70-0d28060d2607"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "4"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 59
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_sequence.count(1)"
+ ],
+ "metadata": {
+ "id": "RrGzKJcNfoQU"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### Lists"
+ ],
+ "metadata": {
+ "id": "LS779pmNfrUS"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "list()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "GKIOFJ6Nftaz",
+ "outputId": "e955f206-b0e5-4863-e5db-61ab80eb9a28"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "[]"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 60
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "list(range(10))"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "PrwShWKLfvf5",
+ "outputId": "6c74de48-4784-4331-a197-3fa5adfa1c01"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 61
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "list(\"Henry Miller\")"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "oB6TC5H_fwzL",
+ "outputId": "dc777fa1-d0d8-42ae-d56b-37f747926854"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['H', 'e', 'n', 'r', 'y', ' ', 'M', 'i', 'l', 'l', 'e', 'r']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 62
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "empty = []\n",
+ "empty"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "UaaEdn_HfzvC",
+ "outputId": "4bc1f5e5-8be4-4df6-a875-55aaa698549e"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "[]"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 63
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "nine = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n",
+ "nine"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "aPiDVWETf2AC",
+ "outputId": "fdf97a39-21ed-448f-e9f6-5ce0a412e008"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 64
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "mixed = [0, 'a', empty, 'WheelHoss']\n",
+ "mixed"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "bFSbs8U2f8dT",
+ "outputId": "44c5d811-0e00-4a13-91bc-5ee617fd1dbe"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "[0, 'a', [], 'WheelHoss']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 65
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "pies = ['cherry', 'apple']\n",
+ "pies\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "5SsBSY_MgFxo",
+ "outputId": "fd7f90b5-30b0-4f81-a33c-2b3f7375e203"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['cherry', 'apple']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 66
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "pies.append('rhubarb')\n",
+ "pies"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "JL_5DG6MgJS-",
+ "outputId": "94db0f8f-582a-425d-a4a0-d354ab79f27a"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['cherry', 'apple', 'rhubarb']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 67
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "pies.insert(1, 'cream')\n",
+ "pies"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "Sy1LRqB1gM2d",
+ "outputId": "cab8738d-9b04-43f9-be67-47fc35407094"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['cherry', 'cream', 'apple', 'rhubarb']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 68
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "desserts = ['cookies', 'paste']\n",
+ "desserts\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "rJxzhN_BgRN2",
+ "outputId": "8e37675f-bc8d-44b0-a9f3-d08be4f53646"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['cookies', 'paste']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 69
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "desserts.extend(pies)\n",
+ "desserts"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "2CULgLqcgeaF",
+ "outputId": "c12f3304-cf06-48c6-be64-4493907a2b3f"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['cookies', 'paste', 'cherry', 'cream', 'apple', 'rhubarb']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 70
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "pies.pop()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "K2DB1flMgj4r",
+ "outputId": "b8b9128a-46d6-4785-baf4-a629888b2704"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'rhubarb'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 71
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "pies"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "ToHbkkQ2glTC",
+ "outputId": "e90974ab-68b1-40aa-db0a-a6cbb8f5b36d"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['cherry', 'cream', 'apple']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 72
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "pies.pop(1)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "V5XyF1kigmkT",
+ "outputId": "4edfa396-85e7-4a47-e55e-60afa572436e"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'cream'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 73
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "pies"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "bAflFL1zgpZx",
+ "outputId": "e9f2500c-a397-44a2-c2c1-e4cfdedaadee"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['cherry', 'apple']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 74
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "pies.remove('apple')\n",
+ "pies"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "LBO5UwFRgqY_",
+ "outputId": "cb921106-f23e-4987-b2ed-e127f999d14b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['cherry']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 75
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "squares = []\n",
+ "for i in range(10):\n",
+ " squared = i*i\n",
+ " squares.append(squared)\n",
+ " \n",
+ " \n",
+ "squares"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "FscCHVEsg7to",
+ "outputId": "08745675-ccb6-42a5-a69e-8d039bc4657d"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 76
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "squares = [i*i for i in range(10)]\n",
+ "squares"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "ODQOjP8xhEMp",
+ "outputId": "5b7574b4-89fa-4444-b4d5-b54545fea98c"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 77
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "squares = [i*i for i in range(10) if i%2==0]\n",
+ "squares"
+ ],
+ "metadata": {
+ "id": "0M6dnI1lhO0m"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### Strings"
+ ],
+ "metadata": {
+ "id": "FVMRBwPdhQ4t"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "str()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "Z2l7U26rhSfM",
+ "outputId": "63b02582-6425-40e3-9267-3ad1ac2ba317"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "''"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 78
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "\"some new string!\""
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "6a6zLs_8hUil",
+ "outputId": "510a972b-a3c5-4e8c-bb66-b89fe8ecdc64"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'some new string!'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 79
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'or with single quotes'"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "gFm-QU1nhXL8",
+ "outputId": "312051ac-ae08-45c7-c4bb-8a418f20a00d"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'or with single quotes'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 80
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "my_list = []\n",
+ "str(my_list)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "ftIV5lAXhbN8",
+ "outputId": "5d6838e5-eb52-4f89-f5cc-3babf13b54ba"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'[]'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 81
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "multi_line = \"\"\"This is a\n",
+ "multi-line string,\n",
+ "which includes linebreaks.\n",
+ "\"\"\"\n",
+ "print(multi_line)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "ohz5En-ohd4r",
+ "outputId": "395758cb-ebd1-4c75-e3d6-0c039c722917"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "This is a\n",
+ "multi-line string,\n",
+ "which includes linebreaks.\n",
+ "\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "input = \" I want more \"\n",
+ "input"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "0Y5VbGv6hmwy",
+ "outputId": "4e0668dd-664e-4206-863b-a08e65f45004"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "' I want more '"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 83
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "input.strip()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "AlRH4g24hydJ",
+ "outputId": "0c36cb1d-3454-4db0-f461-262562bbf84e"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'I want more'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 84
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "input.rstrip()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "x86NfzGCh0A5",
+ "outputId": "c2807c6e-726e-4020-b24c-312e6b6a2d25"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "' I want more'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 85
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "input.lstrip()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "N6QA8BPYh5SH",
+ "outputId": "eb6c3c82-3822-4b10-af4f-e66af708b648"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'I want more '"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 86
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "output = 'Barry'\n",
+ "output.ljust(10)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "3P9uKfneh6tA",
+ "outputId": "4f28ae56-d828-4588-db1c-e20ee0ab2e9c"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'Barry '"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 87
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "output.rjust(10, '*')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "CBhcOiOQjVFt",
+ "outputId": "cac58bd2-4a4a-4e5f-ab17-377be3b0bf4a"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'*****Barry'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 88
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "text = \"Mary had a little lamb\"\n",
+ "text.split()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "bZETnbbCjY_k",
+ "outputId": "e0dea607-7378-4eea-b088-806fd19037d4"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['Mary', 'had', 'a', 'little', 'lamb']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 89
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "url = \"gt.motomomo.io/v2/api/asset/143\"\n",
+ "url.split('/')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "s1Tv9XdSjfPj",
+ "outputId": "db52f86c-d693-4fbb-ed69-5949a2ff6d36"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['gt.motomomo.io', 'v2', 'api', 'asset', '143']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 90
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "url.split('/')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "QH78JnICjiaK",
+ "outputId": "68adf417-8846-49e4-9ac3-d89a97d91ace"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['gt.motomomo.io', 'v2', 'api', 'asset', '143']"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 91
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "items = ['cow', 'milk', 'bread', 'butter']\n",
+ "\" and \".join(items)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "RpLzcEBxjtwK",
+ "outputId": "a88cca8e-ea55-442c-a38a-6fb5d82a3eb8"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'cow and milk and bread and butter'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 92
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "name = \"Bill Monroe\"\n",
+ "name"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "jcVf6IVqjzmx",
+ "outputId": "22bb6429-455e-4e51-d6ee-8fb8fef2a030"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'Bill Monroe'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 93
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "name.upper()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "QIuzpfbWj3s6",
+ "outputId": "e16e438f-1609-47d9-8993-aee1f35b2b9c"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'BILL MONROE'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 94
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "name.title()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "srJXDG65j5H5",
+ "outputId": "ff35a21c-ec6e-47d5-d113-a5b2dc7b596b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'Bill Monroe'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 95
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "name.swapcase()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "Vkav5GQcj8yY",
+ "outputId": "47e0e0fd-ded2-402a-a926-039446167ac9"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'bILL mONROE'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 96
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "name.lower()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "y5zFm18Fj-VB",
+ "outputId": "e58e2ae6-3831-4d87-875e-b18a74f287b1"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'bill monroe'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 97
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "\"William\".startswith('W')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "uO9ebFoikAxx",
+ "outputId": "209abcfe-2fcb-4481-86e8-35fe3e6567e6"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 98
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'William'.startswith('Bill')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "Zxv5tZQ6kD4g",
+ "outputId": "a9157bd9-c67b-4b38-8ab8-c21441492015"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "False"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 99
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'Molly'.endswith('olly')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "VumyNifvkIFI",
+ "outputId": "250532f7-a931-4d65-ab44-640b278310e8"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 100
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'abc123'.isalnum()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "7OoO_6FJkLX4",
+ "outputId": "57bc0441-f842-458a-aa32-f06c48c749bd"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 101
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'abc123'.isalpha()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "7zeQkjpxkOvh",
+ "outputId": "09fc1822-ced8-4e05-bf01-f0ca3eb46092"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "False"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 102
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'abc'.isalpha()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "uK79WoOhkWIX",
+ "outputId": "3d580c6b-d74e-4019-f170-92c90e2925ef"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 103
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'123'.isnumeric()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "O1Ph9K4zkagO",
+ "outputId": "a8623eb4-a520-430a-cc12-64f6f94568bd"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 104
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'Sandy'.istitle()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "4SOAaMTUke5Q",
+ "outputId": "89723318-6d9c-41a5-9d72-f75ee48750e9"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 105
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'Sandy'.islower()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "Rg5m73bKkh8l",
+ "outputId": "adcb49ed-bb2e-497f-efd7-a7938453d169"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "False"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 106
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'SANDY'.isupper()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "InWN0wvSkj81",
+ "outputId": "7d66c97d-a18d-4298-da27-271d0c665faf"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 107
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "\"%s + %s = %s\" % (1, 2, 'three')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "Ec8C3Pz9knmN",
+ "outputId": "d90d2ad3-3038-4ea2-b8a1-e8bd53e1ca3e"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'1 + 2 = three'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 108
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "\"%.3f\" % 1.234567"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "sxco7oSMkva0",
+ "outputId": "822a9143-ecc3-444c-a38d-77793c957911"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'1.235'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 109
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'{} comes before {}'.format('first', 'second')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "8MXuJBnVk1V7",
+ "outputId": "a444b338-d454-410c-aa6c-cf42183fcc8b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'first comes before second'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 110
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "'{1} comes after {0}, but {1} comes before {2}'.format('first', \n",
+ " 'second', \n",
+ " 'third')\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "id": "jZ3MODxJk70O",
+ "outputId": "04e2187b-e169-492a-abee-f19858726b8b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'second comes after first, but second comes before third'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 111
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ ""
+ ],
+ "metadata": {
+ "id": "Arm9OGEYlAmD"
+ },
+ "execution_count": null,
+ "outputs": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/chap03-commandlineTools/__init__.py b/src/chap03-commandlineTools/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/chap03-commandlineTools/always_say_it.py b/src/chap03-commandlineTools/always_say_it.py
new file mode 100644
index 000000000..244a0e6b8
--- /dev/null
+++ b/src/chap03-commandlineTools/always_say_it.py
@@ -0,0 +1,8 @@
+
+def say_it():
+ greeting = 'Hello'
+ target = 'Joe'
+ message = f'{greeting} {target}'
+ print(message)
+
+say_it()
diff --git a/src/chap03-commandlineTools/argparse_example.py b/src/chap03-commandlineTools/argparse_example.py
new file mode 100644
index 000000000..6b69ecd05
--- /dev/null
+++ b/src/chap03-commandlineTools/argparse_example.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+"""
+Command line tool using argparse
+"""
+import argparse
+
+
+def sail():
+ ship_name = 'Your ship'
+ print(f"{ship_name} is setting sail")
+
+
+def list_ships():
+ ships = ['John B', 'Yankee Clipper', 'Pequod']
+ print(f"Ships: {','.join(ships)}")
+
+
+def greet(greeting, name):
+ message = f'{greeting} {name}'
+ print(message)
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description='Maritime control')
+
+ parser.add_argument('--twice', '-t',
+ help='Do it twice',
+ action='store_true')
+
+
+ subparsers = parser.add_subparsers(dest='func')
+
+ ship_parser = subparsers.add_parser('ships',
+ help='Ship related commands')
+ ship_parser.add_argument('command',
+ choices=['list', 'sail'])
+
+
+ sailor_parser = subparsers.add_parser('sailors',
+ help='Talk to a sailor')
+ sailor_parser.add_argument('name',
+ help='Sailors name')
+ sailor_parser.add_argument('--greeting', '-g',
+ help='Greeting',
+ default='Ahoy there')
+
+ args = parser.parse_args()
+ if args.func == 'sailors':
+ greet(args.greeting, args.name)
+ elif args.command == 'list':
+ list_ships()
+ else:
+ sail()
+
diff --git a/src/chap03-commandlineTools/click_example.py b/src/chap03-commandlineTools/click_example.py
new file mode 100644
index 000000000..766499544
--- /dev/null
+++ b/src/chap03-commandlineTools/click_example.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+"""
+Command line tool using click
+"""
+import click
+
+@click.group()
+def cli():
+ pass
+
+@click.group(help='Ship related commands')
+def ships():
+ pass
+
+cli.add_command(ships)
+
+@ships.command(help='Sail a ship')
+def sail():
+ ship_name = 'Your ship'
+ print(f"{ship_name} is setting sail")
+
+@ships.command(help='List all of the ships')
+def list_ships():
+ ships = ['John B', 'Yankee Clipper', 'Pequod']
+ print(f"Ships: {','.join(ships)}")
+
+
+@cli.command(help='Talk to a sailor')
+@click.option('--greeting', default='Ahoy there', help='Greeting for sailor')
+@click.argument('name')
+def sailors(greeting, name):
+ message = f'{greeting} {name}'
+ print(message)
+
+if __name__ == '__main__':
+ cli()
diff --git a/src/chap03-commandlineTools/fire_example.py b/src/chap03-commandlineTools/fire_example.py
new file mode 100644
index 000000000..6c210c234
--- /dev/null
+++ b/src/chap03-commandlineTools/fire_example.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+"""
+Command line tool using fire
+"""
+import fire
+
+
+class Ships():
+ def sail(self):
+ ship_name = 'Your ship'
+ print(f"{ship_name} is setting sail")
+
+ def list(self):
+ ships = ['John B', 'Yankee Clipper', 'Pequod']
+ print(f"Ships: {','.join(ships)}")
+
+
+def sailors(greeting, name):
+ message = f'{greeting} {name}'
+ print(message)
+
+
+class Cli():
+
+ def __init__(self):
+ self.sailors = sailors
+ self.ships = Ships()
+
+
+if __name__ == '__main__':
+ fire.Fire(Cli)
diff --git a/src/chap03-commandlineTools/foo_plugin_a.py b/src/chap03-commandlineTools/foo_plugin_a.py
new file mode 100644
index 000000000..9b832853e
--- /dev/null
+++ b/src/chap03-commandlineTools/foo_plugin_a.py
@@ -0,0 +1,2 @@
+def run():
+ print("Running plugin A")
diff --git a/src/chap03-commandlineTools/foo_plugin_b.py b/src/chap03-commandlineTools/foo_plugin_b.py
new file mode 100644
index 000000000..9b832853e
--- /dev/null
+++ b/src/chap03-commandlineTools/foo_plugin_b.py
@@ -0,0 +1,2 @@
+def run():
+ print("Running plugin A")
diff --git a/src/chap03-commandlineTools/simple_click.py b/src/chap03-commandlineTools/simple_click.py
new file mode 100644
index 000000000..0df506ff2
--- /dev/null
+++ b/src/chap03-commandlineTools/simple_click.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+"""
+Simple Click example
+"""
+import click
+
+@click.command()
+@click.option('--greeting', default='Hiya', help='How do you want to greet?')
+@click.option('--name', default='Tammy', help='Who do you want to greet?')
+def greet(greeting, name):
+ print(f"{greeting} {name}")
+
+
+if __name__ == '__main__':
+ greet()
diff --git a/src/chap03-commandlineTools/simple_fire.py b/src/chap03-commandlineTools/simple_fire.py
new file mode 100644
index 000000000..031549db3
--- /dev/null
+++ b/src/chap03-commandlineTools/simple_fire.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+"""
+Simple Fire example
+"""
+import fire
+
+
+def greet(greeting='Hiya', name='Tammy'):
+ print(f"{greeting} {name}")
+
+def goodbye(goodbye='Bye', name='Tammy'):
+ print(f"{goodbye} {name}")
+
+if __name__ == '__main__':
+ fire.Fire()
diff --git a/src/chap03-commandlineTools/simple_parse.py b/src/chap03-commandlineTools/simple_parse.py
new file mode 100644
index 000000000..7c3fbde7c
--- /dev/null
+++ b/src/chap03-commandlineTools/simple_parse.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+"""
+Command line tool using argparse
+"""
+import argparse
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description='Echo your input')
+ parser.add_argument('message',
+ help='Message to echo')
+
+ parser.add_argument('--twice', '-t',
+ help='Do it twice',
+ action='store_true')
+
+ args = parser.parse_args()
+
+ print(args.message)
+ if args.twice:
+ print(args.message)
+
+
+
diff --git a/src/chap03-commandlineTools/simple_plugins.py b/src/chap03-commandlineTools/simple_plugins.py
new file mode 100644
index 000000000..ff6baed77
--- /dev/null
+++ b/src/chap03-commandlineTools/simple_plugins.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+import fire
+import pkgutil
+import importlib
+
+def find_and_run_plugins(plugin_prefix):
+ plugins = {}
+
+ # Discover and Load Plugins
+ print(f"Discovering plugins with prefix: {plugin_prefix}")
+ for _, name, _ in pkgutil.iter_modules():
+ if name.startswith(plugin_prefix):
+ module = importlib.import_module(name)
+ plugins[name] = module
+
+ # Run Plugins
+ for name, module in plugins.items():
+ print(f"Running plugin {name}")
+ module.run()
+
+if __name__ == '__main__':
+ fire.Fire()
+
+
+
diff --git a/src/chap03-commandlineTools/sys_argv.py b/src/chap03-commandlineTools/sys_argv.py
new file mode 100644
index 000000000..8f4ad2823
--- /dev/null
+++ b/src/chap03-commandlineTools/sys_argv.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+"""
+Simple command line tool using sys.argv
+"""
+import sys
+
+def say_it(greeting, target):
+ message = f'{greeting} {target}'
+ print(message)
+
+if __name__ == '__main__':
+ greeting = 'Hello'
+ target = 'Joe'
+
+ if 'help' in sys.argv:
+ help_message = f"Usage: {sys.argv[0]} --name --greeting "
+ print(help_message)
+ sys.exit()
+
+ if '--name' in sys.argv:
+ # Get position after name flag
+ name_index = sys.argv.index('--name') + 1
+ if name_index < len(sys.argv):
+ name = sys.argv[name_index]
+
+ if '--greeting' in sys.argv:
+ # Get position after greeting flag
+ greeting_index = sys.argv.index('--greeting') + 1
+ if greeting_index < len(sys.argv):
+ greeting = sys.argv[greeting_index]
+
+ say_it(greeting, name)
+
+
diff --git a/src/chap03-commandlineTools/sys_example.py b/src/chap03-commandlineTools/sys_example.py
new file mode 100644
index 000000000..6cc349b28
--- /dev/null
+++ b/src/chap03-commandlineTools/sys_example.py
@@ -0,0 +1,7 @@
+import sys
+
+print(f"sys.exc_info(): {sys.exc_info()}")
+print(f"sys.version: {sys.version}")
+print(f"sys.executable: {sys.executable}")
+print(f"sys.getsizeof(3): {sys.getsizeof(3)}")
+sys.path
diff --git a/src/chap07-Monitoring/web.py b/src/chap07-Monitoring/web.py
new file mode 100644
index 000000000..3b7848bd8
--- /dev/null
+++ b/src/chap07-Monitoring/web.py
@@ -0,0 +1,36 @@
+from flask import Response, Flask
+from time import sleep
+import random
+import prometheus_client
+from prometheus_client import Counter, Histogram
+
+app = Flask('prometheus-app')
+
+REQUESTS = Counter(
+ 'requests', 'Application Request Count',
+ ['endpoint']
+)
+
+TIMER = Histogram(
+ 'slow', 'Slow Requests',
+ ['endpoint']
+)
+
+@app.route('/metrics/')
+def metrics():
+ return Response(
+ prometheus_client.generate_latest(),
+ mimetype='text/plain; version=0.0.4; charset=utf-8'
+ )
+
+
+@app.route('/')
+def index():
+ REQUESTS.labels('/').inc()
+ return 'Development Prometheus-backed Flask App
'
+
+@app.route('/database/')
+def database():
+ with TIMER.labels('/database').time():
+ sleep(random.uniform(1, 3))
+ return 'Completed expensive database operation
'