├── img └── .gitkeep ├── lessonplans ├── .gitkeep ├── parse_timing.py ├── day_3.md ├── day_2.md └── day_1.md ├── tutorials ├── Day_1 │ └── .gitkeep ├── Day_2 │ └── .gitkeep └── Day_3 │ └── .gitkeep ├── README.md ├── LICENSE └── .gitignore /img/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lessonplans/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tutorials/Day_1/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tutorials/Day_2/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tutorials/Day_3/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Intro to PyData Stack tutorial 2 | 3 | Repo for a 3 day tutorial introducing the PyData stack to practitioners 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Ravin Kumar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lessonplans/parse_timing.py: -------------------------------------------------------------------------------- 1 | """ 2 | Parse timing and Sections from markdown file 3 | """ 4 | 5 | from collections import namedtuple 6 | import re 7 | import pandas as pd 8 | 9 | FILE_NAME = "day_3.md" 10 | # Named tuples are convenient and friendly way to keep track of things 11 | 12 | cols = ["Section", "Activity", "Category", "Minutes"] 13 | TIMING_ROW_C = namedtuple("timing_row", cols) 14 | 15 | REGEX_PATTERN = "\ (.+)\((\d+)" 16 | 17 | # Define regex patterns to parse time and title 18 | 19 | 20 | def section_name(line): 21 | """Section Names are on lines with ###""" 22 | if "###" in line and "Section" in line: 23 | section_name = line[3:] 24 | section_name = section_name.rstrip() 25 | return section_name 26 | 27 | 28 | def activity_name_and_minutes(line): 29 | """Parse activity name from each line""" 30 | if "####" in line: 31 | match = re.findall(REGEX_PATTERN, line) 32 | 33 | try: 34 | match = match[0] 35 | activity, time = match[0], match[1] 36 | except IndexError: 37 | raise Exception(f"Broken Line: {line}") 38 | 39 | # Remove leading and trailing whitepaces 40 | activity = activity.rstrip() 41 | 42 | for category in ("instructor", "break", "buffer", 43 | "student", "all", "partner"): 44 | if category in activity.lower(): 45 | break 46 | 47 | return activity, time, category.capitalize() 48 | 49 | return None, None, None 50 | 51 | 52 | file_handle = open(FILE_NAME, "r") 53 | file_lines = file_handle.readlines() 54 | 55 | 56 | timing_rows = [] 57 | for line in file_lines: 58 | possible_section_name = section_name(line) 59 | 60 | if possible_section_name: 61 | _section_name = possible_section_name 62 | 63 | activity, time, category = activity_name_and_minutes(line) 64 | if activity: 65 | assert time, "Activity and time should both appear" 66 | 67 | timing_row = TIMING_ROW_C(_section_name, activity, category, time) 68 | timing_rows.append(timing_row) 69 | 70 | # Write csv to disk 71 | df = pd.DataFrame(timing_rows) 72 | print(df) 73 | df.to_csv(f"{FILE_NAME}_timing_export.csv") 74 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | .DS_Store 131 | -------------------------------------------------------------------------------- /lessonplans/day_3.md: -------------------------------------------------------------------------------- 1 | # Rough Outline Day 3: PyData tools 2 | 3 | ## Section 1: Profiling Python Code 4 | 5 | ### Objectives 6 | * Show various way to profile python code 7 | 8 | ### Section 1.1 "Easy Hacks" to profile python code 9 | #### Instructor Do: Time.time and timeit (20 minutes) 10 | * Show ways to profile snippets of code through taking start and end times 11 | * Show more robust way using built in timeit 12 | 13 | #### Students Do: Fix numerical operation slowdowns (15 minutes) 14 | * Use above methods to time numerical operations when performed in python 15 | * Use numpy to vectorize and improve results 16 | 17 | #### Instructor Do: Review fix numerical operation slowdowns (10 minutes) 18 | 19 | ### Section 1.2 Cprofiler 20 | #### Instructor Do: Introduce cprofiler (15 minutes) 21 | * Show basic use of cprofiler and how to read reports 22 | 23 | #### Students Do: Find slow method in script (15 minutes) 24 | * Using cprofiler find various slowdowns in a python script 25 | * Fix slowdowns and measure results 26 | 27 | ## Section 2: Software Craftmanship 28 | ### Objectives 29 | * Provide high level overview of good practices for python code organization 30 | 31 | ### Section 2.1 Code Craftsmanship 32 | #### Partner Do: Talk about code craftmanship (5 minutes) 33 | * Turn to partner and talk about why code organization is important 34 | * How does it relate to work each persons work, and to their colleagues 35 | 36 | #### All Do: Discuss why code craftsmanship is imporant (10 minutes) 37 | * Go around the room and ask folks what they said in discussions 38 | * Share examples from my work at SpaceX and sweetgreen 39 | 40 | #### Instructor Do: Show examples of code craftsmanship (15 minutes) 41 | * Show how to structure a typical python repository for various use cases 42 | * Importable module 43 | * Analysis 44 | * Generic scripting 45 | * Explain general principles that work well for python 46 | 47 | ## Section 3: Integrating external code in other languages 48 | ### Objectives 49 | * Show methods for integrating C or Fortran code with python 50 | * Note this section is most challenging. Full outline will need some more research, 51 | Basic pattern of showcase and instruction will stay the same 52 | 53 | ### Section 3.1 Docker 54 | #### All Do: Docker Basics (30 minutes) 55 | * Optional section if docker is needed and students need introduction 56 | 57 | ### Section 3.2 Subprocess 58 | Subprocess module allows python to make system calls. This means pythong 59 | can execute some code, then call to the system to execute external code 60 | in fortran or c or whatever, and if data needs to be shared it can be 61 | shared through the disk or OS. 62 | #### All Do: Subprocess module (30 minutes) 63 | * Need to scope specific lecture and activities. Still deciding approach 64 | 65 | ### Section 3.3 Integrating C code 66 | Python has a couple of ways of integrating with C code, as does numpy 67 | and scipy. Need to figure out which approach is most relevant for JPL 68 | #### All Do: Integrating C code (30 minutes) 69 | * *Unfinished* 70 | 71 | ### Section 3.4 Integrating Fortran code 72 | Likely going to teach use of f2py which was used in development of PyMC2. 73 | Would like to understand JPL use case before adding further details 74 | #### All Do: Integrating Fortran code (30 minutes) 75 | * *Unfinished* 76 | 77 | -------------------------------------------------------------------------------- /lessonplans/day_2.md: -------------------------------------------------------------------------------- 1 | # Rough Outline Day 2: PyData tools 2 | Note: This is the rough outline meant scaffold full tutorial development 3 | 4 | ## Section 1: PyData/Scientific Tooling 5 | Go through pydata tooling showing use cases but also explaining history 6 | and community around the tools 7 | 8 | ### Objectives 9 | * Demonstrate use of notebooks 10 | * Explain how efficient numerical computation is typically performed 11 | * Demonstrate how to generate visualizations in python 12 | * Demonstrate file IO in python 13 | * Show how data cleaning and munging is done using Pandas 14 | 15 | 16 | ### Section 1.1: Intros and class welcome 17 | 18 | #### Instructor Do: Introduction to class (15 minutes) 19 | * If class is different from Day 1 repeat below 20 | * Introduce myself and background 21 | * Explain why pydata stack has been useful for me professionally and personally 22 | * Talk through agenda 23 | 24 | #### Partners Do: Fizzbuzz Warmup (15 minutes) 25 | * Write fizzbuzz from scratch with a partner 26 | * Exercise ensures students are comfortable with python and have a working 27 | environment 28 | 29 | #### Instructor Do: Review Fizzbuzz Warmup (5 minutes) 30 | * Assumption is that students know python so review is short 31 | 32 | #### All Do: What are you interested in today? (10 minutes) 33 | * Purpose is to have students think ahead as to what they want to learn 34 | * Instructor learns what students specifically want to know to better 35 | target lecture 36 | 37 | 38 | 39 | ## Section 2: Pydata Tooling 40 | 41 | ### Section 2.0 Conda? 42 | * Question: Are students familiar with conda or virtual envs? If not will 43 | need to cover 44 | 45 | ### Section 2.1 Jupyter Notebooks 46 | 47 | #### Instructor Do: Show jupyter notebook functionality (25 minutes) 48 | * Explain jupyter notebook to students 49 | * Show to start server and get to web interface 50 | * Explain portions of interface, covering common widgets 51 | * Show how to create a python notebook with kernel 52 | * Show how to add cells and run code 53 | * Show how to add markdown cells for annotation 54 | * Ensure students understand that notebooks don't have to execute top to bottom 55 | * Show how to export notebooks to html 56 | * Preview remainder of day showing an end to end example of loading a file in pandas 57 | and plotting a couple of graphs 58 | 59 | 60 | #### Students Do: Fizzbuzz in notebooks (15 minutes) 61 | * Have students start a jupyter notebook 62 | * Have them run their fizzbuzz program in the notebook 63 | * Ask them to add human understandable notes in markdown cells 64 | * Have them export their results to html 65 | 66 | 67 | #### Instructor Do: Review Fizzbuzz in notebooks (10 minutes) 68 | 69 | 70 | ### Section 2.2 Numpy 71 | 72 | #### Instructor Do: Numpy primer (20 minutes) 73 | * Explain why numpy is the foundational library to scientific ecosystem 74 | * Explain how numpy differs from lists 75 | * Demonstrate 76 | * Array creation 77 | * Array broadcasting 78 | * Array slicing 79 | * Show other methods available in numpy 80 | * Show students speed difference of numpy over python lists 81 | 82 | 83 | #### Students Do: Ordinary Least Squares Regression in Numpy (20 minutes) 84 | * Solve ordinary least squares regression using numpy matrix algebra 85 | * Solve using numpy lin alg method 86 | 87 | 88 | #### Instructor Do: Review Least Squares Regression (20 minutes) 89 | 90 | ### Section 2.3: Scipy Overview 91 | 92 | #### Instructor Do: Scipy Overview (20 minutes) 93 | * General overview of api 94 | * Generating random distributions 95 | * Using optimizer functions 96 | * [Reading matlab files](https://scipy-cookbook.readthedocs.io/items/Reading_mat_files.html) 97 | 98 | 99 | #### Students Do: Optimize newspaper inventory holding (20 minutes) 100 | * Given parameters for newspaper sales distribution 101 | determine the optimal amount of inventory to hold 102 | 103 | #### Instructor Do: Review newspaper inventory holding (15 minutes) 104 | 105 | ### Section 2.4: Matplotlib Overview 106 | * Cover matplotlib object oriented api 107 | * Mention stateful api and encourage students to use OO api 108 | * Show how to plot various 2D plots 109 | * Show how to plot 3D plots 110 | 111 | #### Instructor Do: Show matplotlib basics and api (20 minutes) 112 | * Showcase matplotlib functionality, in particular 113 | * Fig and axes 114 | * Anatomy of plot 115 | * Multiple subplots 116 | * [3D plots](https://matplotlib.org/3.1.1/gallery/mplot3d/subplot3d.html) 117 | 118 | 119 | #### Partners Do: Plot the previous data in 2D (20 minutes) 120 | * Have students revisit previous exercises and plot 121 | * Linear regression from numpy section 122 | * Demand histogram bin in second example 123 | 124 | #### Instructor Do: Review 2D plots (15 minutes) 125 | 126 | #### Everyone Do: 3D plots (20 minutes) 127 | * Show how 3D plots can be generated using similar api 128 | * Have students follow along while instructor produces plot 129 | 130 | 131 | ### Section 2.5: Pandas 132 | * Explain history of pandas 133 | * Why its so useful in data space 134 | * Why its one of my most used tools 135 | 136 | #### Instructor Do: Pandas Basics and Data Selection (15 minutes) 137 | * Show manual creation of Pandas Dataframe 138 | * Indexing and selecting or rows 139 | * Bracket api, iloc and loc 140 | * Adding a column 141 | * Difference between Series and Dataframe 142 | * How to read pandas documentation 143 | 144 | 145 | #### Instructor Do: Loading external data (20 minutes) 146 | * Show how to load data from 147 | * CSV 148 | * Excel 149 | * Relational Database (we'll use postgres) 150 | * [HDF5](https://www.neonscience.org/hdf5-intro-python) 151 | * Show to to save data to disk as well 152 | 153 | #### Students Do: Loading external data (10 minutes) 154 | * Load the iris dataset from the internet 155 | * Write the dataframe to disk in various formats 156 | 157 | #### Instructor do: Loading external data (5 minutes) 158 | 159 | #### Instructor Do: Groupby (15 minutes) 160 | * Show group by's functionality using standard functions 161 | * How to write custom group by functions 162 | 163 | #### Students Do: Count and average flowers (10 minutes) 164 | * Using iris dataset count number and average of attributes in each group 165 | 166 | #### Instructor Do: Review groupby (5 minutes) 167 | 168 | #### Instructor Do: Advanced dataframe manipulation (20 minutes) 169 | * Show API for multiindex and pivot tables 170 | * Show `pd.join` and `pd.merge` functionality 171 | 172 | #### Students Do: Clean dataset for analysis and presentation (25 minutes) 173 | * Give students a couple messy datasets 174 | * Ask them to either mutate the dataframe for presentation or for analysis 175 | 176 | #### Instructor Do: Review Dataset Cleaning (10 minutes) 177 | 178 | ## Section 3: Conclusion 179 | ### Section 3.1 Wrap up 180 | #### All Do: Class discussion (20 minutes) 181 | * Ask students how they can apply what they learned to their work 182 | * Answer any remaining questions 183 | 184 | -------------------------------------------------------------------------------- /lessonplans/day_1.md: -------------------------------------------------------------------------------- 1 | # Rough Outline Day 1: Code Craftsmanship and Python Language Introduction 2 | Note: This is the rough outline meant scaffold full tutorial development 3 | 4 | ## Section 1: Introductions and Class format 5 | Purpose of this section is to establish social familiarity with everyone 6 | participating in class and ensure code environments are working 7 | 8 | ### Objectives 9 | * Introduce myself to class and provide my background 10 | * Instructor to learn the names of all the individuals 11 | * Have class introduce themselves to each other 12 | * Learn specific motivations of why students are in class 13 | * Run simple code example to be sure everyone has working environment 14 | * Communicate agenda and set pacing for class 15 | 16 | 17 | ### Section 1.1 Intros 18 | #### Instructor Do: Light Introduction (10 minutes) 19 | * Introduce myself and background 20 | * Explain why pydata stack has been useful for me professionally and personally 21 | 22 | #### Students Do: Introductions to each other (10 minutes) 23 | * Ask students to pair up 24 | * Talk to each other about their motivations 25 | * In last 5 minutes call on students and ask them to speak for their partner 26 | as to why they came to class 27 | 28 | 29 | ## Section 2: Introduction to Python 30 | Introduce python language spec to class. Give some "soft" history 31 | and explain relevant details of why python differs from other popular 32 | languages like java, or matlab. 33 | 34 | 35 | ### Objectives 36 | * Introduce python language fundamentals 37 | * Build up a rock paper scissors game over a series of examples 38 | 39 | 40 | ### Section 2.1 Executing Code 41 | #### Instructor Do: Explain interpreters, repl and executing code (10 minutes) 42 | * Explain how python is 43 | * language spec, and there are numerous versions 44 | * that there are numerous interpreters, cython being most common 45 | * There are multiple ways to execute python code. We're starting with 2 46 | * Note how python 2 is dead 47 | * Show how to start a repl and run `print("Hello World!")` in a terminal 48 | * Show how these same commands can be saved in a file and run 49 | * Show the most important language feature, how to add comments 50 | 51 | #### Students Do: Start at terminal and print hello world (5 minutes) 52 | * Start a terminal and execute `print("Hello World!")` in repl 53 | * Run a `hello.py` file from disk 54 | * Secondary purpose is to verify everyone's python installations are working 55 | 56 | #### Buffer (15 Minutes) 57 | * Buffer of time in case issues arise in All do that require trouble shooting 58 | 59 | ### Section 2.2 Basic Datatypes 60 | #### Instructor Do: Python interpreters, basic data types, and operators (25 Minutes) 61 | * In terminal show students the following basic datatypes 62 | * Numeric (int/floats) 63 | * Strings 64 | * Bools 65 | * None 66 | * Show comparison operators such as `<`, `==`, 67 | 68 | * Show how variables are assigned in python with `=` operator 69 | * Explain how duck typing in python works using `+` operator 70 | * Show that adding `2 + 2` returns `4` but `'2' + '2'` return `22` 71 | * Show how if python can't "figure it out" an exception is raised 72 | * Showcase python builtins, in particular `type, len, str, int, bool` 73 | 74 | #### Students Do: Fix the broken examples (10 minutes) 75 | * Give students a .py with various working and failing lines, due to object 76 | mismatch. Ask students to inspect data types and fix to achieve intended result 77 | 78 | #### Instructor Do: Review broken examples exercise (5 minutes) 79 | * Answer any questions from exercise 80 | 81 | ### Section 2.3 Everything is an object and python documentation 82 | #### Instructor Do: Python interpreters, basic data types, and operators (10 Minutes) 83 | * Show how everything is python is an object with methods associated with it 84 | * Showcase examples like `str.lower()` or `.isupper()` 85 | * Point students to python documentation https://docs.python.org/3/library/stdtypes.html#string-methods 86 | 87 | #### Students Do: Try out various methods (10 minutes) 88 | * Students try various methods on and ints from documentation 89 | 90 | #### Instructor Do: Review various methods exercise (5 minutes) 91 | 92 | ### Section 2.4 Collections 93 | #### Instructor Do: Introduce Collections and in operator (20 minutes) 94 | * In terminal show students the following datatypes 95 | * Lists 96 | * Tuples 97 | * Dictionaries 98 | * Sets 99 | * Show python in operator 100 | * Showcase python slicing `[]` syntax 101 | 102 | #### Students Do: Collection practice (15 minutes) 103 | * Collections golf: Get particular values from collections 104 | * Mutate collection, (or don't if its a tuple) 105 | * Check what's in a collection 106 | * With dictionaries check keys vs values 107 | 108 | #### Instructor Do: Collection practice review (10 minutes) 109 | * Collections golf: Get particular values from collections 110 | * Mutate collection, (or don't if its a tuple) 111 | * Check what's in a collection 112 | * With dictionaries check keys vs values 113 | 114 | #### Instructor Do: Collection practice review (5 minutes) 115 | 116 | 117 | #### Lunch Break (60 minutes) 118 | 119 | ### Section 2.5 Control Flow, Conditionals, and builtins 120 | 121 | #### Instructor Do: For, While, Try, Except Conditionals (25 minutes) 122 | * Show python syntax for 123 | * For 124 | * While 125 | * Conditionals 126 | * How to accept user input with `input()` and `range` function 127 | * Mention the idea of generators but don't cover deeply 128 | * Show python syntax for Try Except 129 | * Provide guidelines on when to catch exception and when to let them raise 130 | 131 | #### Students Do: Conditionals practice (20 minutes) 132 | * Programatic counter from user input 133 | * Continuous ask for input until exit command is given 134 | * Mutate collection, (or don't if its a tuple) 135 | * Check what's in a collection 136 | * With dictionaries check keys vs values 137 | 138 | 139 | #### Instructor Do: Review Conditionals practice (10 minutes) 140 | 141 | ### Section 2.6 Functions 142 | #### Instructor Do: Functions and args (20 minutes) 143 | * Introduce functions syntax, In particular 144 | * Positional args 145 | * Keyword args 146 | * Return 147 | 148 | #### Students Do: Write reusable code (20 minutes) 149 | * Introduce functions syntax, In particular 150 | * Positional args 151 | * Keyword args 152 | 153 | #### Instructor Do: Write reusable code (10 minutes) 154 | 155 | ### Section 2.7 Imports 156 | 157 | #### Instructor Do: Import syntax (10 minutes) 158 | * Show how python can import built in modules like random 159 | * Cover import from and as 160 | 161 | #### Students Do: Import random, generate random numbers (10 minutes) 162 | * Import the random module and generate random numbers 163 | * Import math and perform operations on numbers 164 | 165 | #### Instructors Do: Review random, generate random numbers (5 minutes) 166 | 167 | ### Section 2.8 Objects and classes 168 | 169 | #### Instructor Do: Object syntax (25 minutes) 170 | * Show object definition, including methods 171 | * Demonstrate object inheritance 172 | 173 | #### Students Do: Defining cars (20 minutes) 174 | * Ask students to create a vehicle base class 175 | * Define methods to describe vehicle 176 | 177 | #### Instructors Do: Review classes (10 minutes) 178 | 179 | ### Section 2.9 Splitting code apart 180 | 181 | #### Instructor Do: Creating own modules (10 minutes) 182 | * Show object definition, including methods 183 | * Demonstrate object inheritance 184 | 185 | ### Section 2.10: Advanced topics 186 | 187 | #### Instructor Do: Topics not covered by of interest (10 minutes) 188 | * Mention advanced topics such as 189 | * Generators 190 | * Context Manager 191 | * Python packaging 192 | 193 | --------------------------------------------------------------------------------