├── 00. Introduction.ipynb ├── 01. Overview.ipynb ├── 02. Debugging.ipynb ├── 03. Variables.ipynb ├── 04. Printing.ipynb ├── 05. Classes and Objects.ipynb ├── 06. Functions.ipynb ├── 07. Loops.ipynb ├── 08. Input.ipynb ├── 09. If Statements.ipynb ├── 10. Lists and Tuples.ipynb ├── 11. Dictionaries.ipynb ├── 12. Plotting.ipynb ├── Basic Python Knowledge.ipynb ├── BeginPython.png ├── README.md ├── TCLab Help.ipynb ├── XX. Final Project.ipynb ├── _config.yml └── module_images ├── BeginPython00.png ├── BeginPython01.png ├── BeginPython02.png ├── BeginPython03.png ├── BeginPython04.png ├── BeginPython05.png ├── BeginPython06.png ├── BeginPython07.png ├── BeginPython08.png ├── BeginPython09.png ├── BeginPython10.png ├── BeginPython11.png ├── BeginPython12.png └── BeginPythonXX.png /00. Introduction.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Introduction to Python\n", 8 | "\n", 9 | "![python](https://apmonitor.com/che263/uploads/Begin_Python/python.png)\n", 10 | "\n", 11 | "Welcome to this introductory course on Python! This course is intended to help you start programming in Python from little or no prior experience. There are video tutorials for each exercise if you have questions along the way.\n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=EO_YpBs8cs0&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Intro to Python](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython00.png)](https://www.youtube.com/watch?v=EO_YpBs8cs0&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Introduction to Python\")\n", 16 | "\n", 17 | "One of the unique things about this course is that you work on basic elements to help you with a temperature control project. You will see your Python code have a real effect by adjusting heaters to maintain a target temperature, just like a thermostat in a home or office.\n", 18 | "\n", 19 | "![temperature](https://apmonitor.com/che263/uploads/Begin_Python/temperature.png)\n", 20 | "\n", 21 | "One of the best ways to start or review a programming language is to work on a simple project. These exercises are designed to teach basic Python programming skills to help you design a temperature controller. Temperature control is found in many applications such as home or office HVAC, manufacturing processes, transportation, and life sciences. Even our bodies regulate to a specific temperature.\n", 22 | "\n", 23 | "![buildings](https://apmonitor.com/che263/uploads/Begin_Python/buildings.png)\n", 24 | "\n", 25 | "This project is to regulate the temperature of the TCLab (Temperature Control Lab). Each TCLab has thermochromic (changes color with temperature) paint that turns from black to purple when the temperature reaches the target temperature of 37°C (99°F).\n", 26 | "\n", 27 | "![pid control](https://apmonitor.com/pdc/uploads/Main/pid_control.gif)\n", 28 | "\n", 29 | "The first thing that you'll need is to install Anaconda and run the Jupyter notebook. [Download Anaconda to use Jupyter](https://www.anaconda.com/distribution/) or [watch a video on how to install it](https://youtu.be/LrMOrMb8-3s).\n", 30 | "\n", 31 | "[![Install Anaconda](http://img.youtube.com/vi/LrMOrMb8-3s/0.jpg)](https://www.youtube.com/watch?v=LrMOrMb8-3s \"Install Anaconda\")\n", 32 | "\n", 33 | "The video shows how to install Anaconda and a few things you can do with the Jupyter Notebook. Examples are with Jupyter Notebook and Spyder. There are [additional instructions on installing Python and managing modules](https://apmonitor.com/pdc/index.php/Main/InstallPython)." 34 | ] 35 | } 36 | ], 37 | "metadata": { 38 | "kernelspec": { 39 | "display_name": "Python 3", 40 | "language": "python", 41 | "name": "python3" 42 | }, 43 | "language_info": { 44 | "codemirror_mode": { 45 | "name": "ipython", 46 | "version": 3 47 | }, 48 | "file_extension": ".py", 49 | "mimetype": "text/x-python", 50 | "name": "python", 51 | "nbconvert_exporter": "python", 52 | "pygments_lexer": "ipython3", 53 | "version": "3.7.4" 54 | } 55 | }, 56 | "nbformat": 4, 57 | "nbformat_minor": 2 58 | } 59 | -------------------------------------------------------------------------------- /01. Overview.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 1. Overview\n", 8 | "\n", 9 | "### Background\n", 10 | "\n", 11 | "![hatch](https://apmonitor.com/che263/uploads/Begin_Python/hatch.png)\n", 12 | "\n", 13 | "You have eggs that need to hatch in an incubator. One option is to constantly check the temperature and adjust the heaters manually. Another way is to automate the temperature control by constantly checking the temperature and adjusting the heaters with Python. Unfortunately, you only get three eggs for the test and one attempt to get it right. You do have a simulator of the incubator (TCLab) so you can practice Python, without having to worry about mistakes. The purpose of this lab is to develop a temperature controller (like a thermostat) that could be used for an egg incubator. There are other factors such as humidity and turning the eggs that are important with incubators but we'll only focus on the temperature for this project.\n", 14 | "\n", 15 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=wuWLVbBFPuc&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 16 | "\n", 17 | "[![Course Overview](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython01.png)](https://www.youtube.com/watch?v=wuWLVbBFPuc&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Course Overview\")\n", 18 | "\n", 19 | "### Introduction\n", 20 | "\n", 21 | "Every programmer must have basic background knowledge before using the language in more complex projects. This tutorial steps through basic programming skills to build the more complex incubator temperature control. The introductory 12 exercises are designed to be completed in 2-3 hours (15-20 minutes each) but sections can be skipped if you already have the background knowledge.\n", 22 | "\n", 23 | "If you want to do well in monitoring and controlling the egg temperature, you should work through the basic information. For those who already have experience with Python, this background knowledge also teaches the `tclab` package functions.\n", 24 | "\n", 25 | "1. Overview (this lesson)\n", 26 | "2. Debugging\n", 27 | "3. Variables\n", 28 | "4. Printing\n", 29 | "5. Classes and Objects\n", 30 | "6. Functions\n", 31 | "7. Loops\n", 32 | "8. Input\n", 33 | "9. If Statements\n", 34 | "10. Lists and Tuples\n", 35 | "11. Dictionaries\n", 36 | "12. Plotting\n", 37 | "\n", 38 | "It is best to follow the lessons in these steps because the later lessons build upon the information from the prior lessons.\n", 39 | "\n", 40 | "### Install TCLab Module and Test LED\n", 41 | "\n", 42 | "![connections_no_power](https://apmonitor.com/che263/uploads/Begin_Python/connections_no_power.png)\n", 43 | "\n", 44 | "You need the TCLab to do the exercises. As a first step, plug in the TCLab (USB blue cable only) and install the package with `pip install tclab` or by running the cell below (`Ctrl+Enter`). Restart the Python kernal with `Kernel...Restart & Run All` from the menu if there is an error importing `tclab` after the installation." 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "# install tclab\n", 54 | "try:\n", 55 | " import tclab\n", 56 | "except:\n", 57 | " # Needed to communicate through usb port\n", 58 | " !pip install --user pyserial\n", 59 | " # The --user is put in for accounts without admin privileges\n", 60 | " !pip install --user tclab \n", 61 | " # restart kernel if this doesn't import\n", 62 | " import tclab\n", 63 | " \n", 64 | "import time\n", 65 | "\n", 66 | "# tclab test\n", 67 | "lab = tclab.TCLab()\n", 68 | "lab.LED(100) # turn on LED\n", 69 | "time.sleep(5) # wait 5 seconds\n", 70 | "lab.LED(0) # turn off LED\n", 71 | "lab.close()" 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": {}, 77 | "source": [ 78 | "There are seperate Jupyter notebook files to help with TCLab installation. There are also [Frequently Asked Questions](https://apmonitor.com/pdc/index.php/Main/ArduinoSetup) for setup and troubleshooting. More information on installation of TCLab package is in **5. Objects Lesson** and also in the IPython notebook __TCLab Help__." 79 | ] 80 | } 81 | ], 82 | "metadata": { 83 | "kernelspec": { 84 | "display_name": "Python 3", 85 | "language": "python", 86 | "name": "python3" 87 | }, 88 | "language_info": { 89 | "codemirror_mode": { 90 | "name": "ipython", 91 | "version": 3 92 | }, 93 | "file_extension": ".py", 94 | "mimetype": "text/x-python", 95 | "name": "python", 96 | "nbconvert_exporter": "python", 97 | "pygments_lexer": "ipython3", 98 | "version": "3.7.5" 99 | } 100 | }, 101 | "nbformat": 4, 102 | "nbformat_minor": 2 103 | } 104 | -------------------------------------------------------------------------------- /02. Debugging.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 2. Debugging\n", 8 | "\n", 9 | "![debug](https://apmonitor.com/che263/uploads/Begin_Python/debug.png)\n", 10 | "\n", 11 | "One of the biggest time consuming parts of programming is debugging, or resolving mistakes in the program. This is true for every language because the computer needs exact commands, which is very important for precise measurements and temperature control. A few steps can limit the time you are searching for mistakes, instead of completing the project. \n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=n1BlQkoWbdM&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Pseudo-Code and Debugging](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython02.png)](https://www.youtube.com/watch?v=n1BlQkoWbdM&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Pseudo-Code and Debugging\")\n", 16 | "\n", 17 | "### Steps for more effective programming\n", 18 | "\n", 19 | "![list](https://apmonitor.com/che263/uploads/Begin_Python/list.png)\n", 20 | "\n", 21 | "1. Start with understanding the big picture. Go over the whole program architecture to find high-level gaps. Do this in whichever way suits you best, such as drawing a flowchart. For the egg incubator, the program scope is to diagram what you actually need to do to help an egg hatch.\n", 22 | "\n", 23 | "2. Start by outlining your code, writing **high-level instructions (pseudo-code)** what you want each section of the code to do. Break it into more specific tasks. You can do this even without understanding the basics of Python. Once you learn Python basics, you can translate these high level instructions into code. Organizing the outline helps to make sure your programming isn't more complex than it needs to be.\n", 24 | "\n", 25 | "3. Program the specific tasks and connect them together. Direct tasks make it significantly easier to program because the program is modular. It is a lot harder to program something if the program is large and complex. For the incubator, this may be programming something specific like how hard the heater should work, based on a low temperature reading.\n", 26 | "\n", 27 | "4. Test and fix problems. This is debugging, but don’t only test the whole project after you've completed all of the programming. It is much easier to find a problem if you test every once in a while, when you are programming smaller parts. A good way to do this is grab a specific piece of code, run it on a separate file, and see if it does the job you want. An example would be fixing when the heater should stop working, so the egg doesn't go over temperature.\n", 28 | "\n", 29 | "The better you follow these steps the less time you will have to spend fixing problems in your code for your incubator, or just Python programs in general.\n", 30 | "\n", 31 | "### Activity\n", 32 | "\n", 33 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 34 | "\n", 35 | "Fix the errors in the following code cells. Use the error messages to help you locate the problems." 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": null, 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [ 44 | "print('Program to Hatch an Egg) # hint: look for a missing ' character" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "target temperature = 37 # hint: variable names cannot have spaces" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": null, 59 | "metadata": {}, 60 | "outputs": [], 61 | "source": [ 62 | "current_temperature = 30\n", 63 | "target_temperature = 37\n", 64 | "difference = target_temperature - current_temperature\n", 65 | "print(difference + 'degC') # hint: use str(difference) to make it a string" 66 | ] 67 | } 68 | ], 69 | "metadata": { 70 | "kernelspec": { 71 | "display_name": "Python 3", 72 | "language": "python", 73 | "name": "python3" 74 | }, 75 | "language_info": { 76 | "codemirror_mode": { 77 | "name": "ipython", 78 | "version": 3 79 | }, 80 | "file_extension": ".py", 81 | "mimetype": "text/x-python", 82 | "name": "python", 83 | "nbconvert_exporter": "python", 84 | "pygments_lexer": "ipython3", 85 | "version": "3.7.4" 86 | } 87 | }, 88 | "nbformat": 4, 89 | "nbformat_minor": 2 90 | } 91 | -------------------------------------------------------------------------------- /03. Variables.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 3. Variables\n", 8 | "\n", 9 | "![chickens](https://apmonitor.com/che263/uploads/Begin_Python/chickens.png)\n", 10 | "\n", 11 | "Variables store information and are objects in Python. For example, if you wanted to keep a set temperature for an egg, you would type ```egg = 37.5``` (°C) or ```egg = 99.5``` (°F). The first part tells what the variable will be called, and the value after the ```=``` tells what is being stored. \n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=q6QOsauDyPg&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Variable Types](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython03.png)](https://www.youtube.com/watch?v=q6QOsauDyPg&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Variable Types\")\n", 16 | "\n", 17 | "### Types of Variables\n", 18 | "\n", 19 | "![idea](https://apmonitor.com/che263/uploads/Begin_Python/idea.png)\n", 20 | "\n", 21 | "There are many types of value types but for now, we’ll just go through the basics. You can run the code, but in this case the computer won't tell you anything, because it is only storing values. \n", 22 | "\n", 23 | "While you can run a program by clicking the run button towards the top of the screen, a better way to run cells individually is to click a cell, then type ```Ctrl``` and ```Enter```. Running this way means you're running one cell at a time, instead of all cell. Jupyter Notebooks can also have the run button to the left of the program cell." 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "#### Integers\n", 31 | "Integers, or ```int```, are the value of a basic, whole number like ```99```. You can use the function `int(99.5)` to convert a number to an integer `99` as it removes any numbers after the decimal." 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "temp = 99" 41 | ] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": {}, 46 | "source": [ 47 | "#### Floats\n", 48 | "Floating point numbers, or ```float```, are also numbers, but with decimals like ```4.72```." 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": null, 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "price = 34.09" 58 | ] 59 | }, 60 | { 61 | "cell_type": "markdown", 62 | "metadata": {}, 63 | "source": [ 64 | "#### Strings\n", 65 | "Strings, or ```str```, are words or text, usually typed like ```\"hi\"```. You can use double ```\"\"``` or single ```''``` quotes." 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": null, 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "greeting = \"hi\"" 75 | ] 76 | }, 77 | { 78 | "cell_type": "markdown", 79 | "metadata": {}, 80 | "source": [ 81 | "#### Boolean\n", 82 | "Boolean, or ```bool```, is a ```True``` or ```False``` value. They both need to start with a capital letter." 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": null, 88 | "metadata": {}, 89 | "outputs": [], 90 | "source": [ 91 | "answer = True" 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "metadata": {}, 97 | "source": [ 98 | "### Comments \n", 99 | "Comments are ignored by Python and are words in a program to explain the code. They are created with the ```#``` symbol and can appear to the right of a statement or on a separate line." 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": null, 105 | "metadata": {}, 106 | "outputs": [], 107 | "source": [ 108 | "variable = \"random\" # This is a comment" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": {}, 114 | "source": [ 115 | "### Rules of Variables\n", 116 | "\n", 117 | "![list](https://apmonitor.com/che263/uploads/Begin_Python/list.png)\n", 118 | "\n", 119 | "#### Variable Naming\n", 120 | "In order to properly name a variable, it can only start with a __letters__ or an __underscore__. After the first character you can use __letters, __numbers__, and __underscores__. \n", 121 | "\n", 122 | "##### Python variables can start with:\n", 123 | "\n", 124 | "```_``` or **letters** (Recommended to start with lowercase)\n", 125 | "\n", 126 | "##### And are continued with:\n", 127 | "\n", 128 | "**Numbers** ```0-9``` ,**letters**, and __underscores__. Example:\n", 129 | "\n", 130 | "```python\n", 131 | "_this_is_a_variable_27 = \"Incubator Temperature Control\"```\n", 132 | "\n", 133 | "If you want to check your understanding, run incorrect variables and then fix the variable names to whatever you want. Make sure the variable name follows the naming rules." 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": null, 139 | "metadata": {}, 140 | "outputs": [], 141 | "source": [ 142 | "375 = \"Important Egg Data\" # Can't start with a number, change it to something else\n", 143 | "\n", 144 | "badtemp$ = 6 # Look for the symbol, delete it" 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "metadata": {}, 150 | "source": [ 151 | "### Variable Properties\n", 152 | "Variables can be assigned a value such as a string, integer, or float. If you assign them again later in the code it simply changes to that new assignment. For example, the code below would first use ```3``` for ```test```, but after would use ```egg``` instead. Unlike other programming languages, Python variables are mutable (can change type). You can see the variable type with `type(test)`." 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": null, 158 | "metadata": {}, 159 | "outputs": [], 160 | "source": [ 161 | "test = 3\n", 162 | "test = \"egg\"\n", 163 | "type(test)" 164 | ] 165 | }, 166 | { 167 | "cell_type": "markdown", 168 | "metadata": {}, 169 | "source": [ 170 | "### Variable Usage\n", 171 | "Variables can be used in math or when you are trying to show a result, which is very useful but they do have restrictions. Different types of values typically can't be added together, such as ```5 + \"degC\"```. This can be fixed if you need __5degC__ to be output. Change the value type of ```5``` manually into a __string__, ```str(5) + \"degC\"```." 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "execution_count": null, 177 | "metadata": {}, 178 | "outputs": [], 179 | "source": [ 180 | "combined_str = \"right\" + 'left'\n", 181 | "combined_int = 4 + 2\n", 182 | "combined_int_str = str(5) + \"degC\"" 183 | ] 184 | }, 185 | { 186 | "cell_type": "markdown", 187 | "metadata": {}, 188 | "source": [ 189 | "### Activity\n", 190 | "\n", 191 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 192 | "\n", 193 | "Make one variable for every variable type, string, integer, float, and boolean.\n", 194 | "\n", 195 | "(The ```#``` symbol makes the text behind it a comment. Those words are just for discribing the program, they don't do anything to the code.)" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": null, 201 | "metadata": {}, 202 | "outputs": [], 203 | "source": [ 204 | "string = \n", 205 | "integer = \n", 206 | "float1 = # \"float\" in code is already assigned so it's changed to something else, to avoid errors\n", 207 | "boolean = " 208 | ] 209 | }, 210 | { 211 | "cell_type": "markdown", 212 | "metadata": {}, 213 | "source": [ 214 | "Try making your own variable to store your chicken's name. Make sure to change the assignment name from ```yourVariable``` to what the information is about so you remember. \n", 215 | "\n", 216 | "Then combine the variables, ```x``` and ```y```, below by changing their types to __strings__. If you get stuck, the example just above changes ```integer``` 5 into a string. Use the same code on x and y." 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": null, 222 | "metadata": {}, 223 | "outputs": [], 224 | "source": [ 225 | "ChickenName = \n", 226 | "x = True # This is a Boolean\n", 227 | "y = 236.4 # This is a float\n", 228 | "combined = x + y # Make x and y strings" 229 | ] 230 | } 231 | ], 232 | "metadata": { 233 | "kernelspec": { 234 | "display_name": "Python 3", 235 | "language": "python", 236 | "name": "python3" 237 | }, 238 | "language_info": { 239 | "codemirror_mode": { 240 | "name": "ipython", 241 | "version": 3 242 | }, 243 | "file_extension": ".py", 244 | "mimetype": "text/x-python", 245 | "name": "python", 246 | "nbconvert_exporter": "python", 247 | "pygments_lexer": "ipython3", 248 | "version": "3.7.4" 249 | } 250 | }, 251 | "nbformat": 4, 252 | "nbformat_minor": 2 253 | } 254 | -------------------------------------------------------------------------------- /04. Printing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 4. Printing\n", 8 | "\n", 9 | "![exercise](https://apmonitor.com/che263/uploads/Begin_Python/exercise.png)\n", 10 | "\n", 11 | "Printing is displaying values to the screen. The word `print` comes from the time when programs previously put ink on paper. You use the built-in python __function__ ```print()``` to output values.\n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=CCPNIocw0_Y&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Print](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython04.png)](https://www.youtube.com/watch?v=CCPNIocw0_Y&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Print\")\n", 16 | "\n", 17 | "You could use this to tell you what the current temperature of the egg is and when to display it. Get more practice by putting something different in the function and running the program." 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": null, 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [ 26 | "print(\"Chicken Hatches: 'Hello World!'\") # Put something in between the \"\" symbols" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "metadata": {}, 32 | "source": [ 33 | "You can also print functions, this function is one that will tell the information type that is stored in a variable. The `type` function will return ``````, `str`, `bool`, `float`, whatever is stored in the variable." 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "eggs = 200 # integer variable\n", 43 | "print(type(eggs))\n", 44 | "\n", 45 | "egg_type = \"Platypus\" # string variable\n", 46 | "print(type(egg_type))\n", 47 | "\n", 48 | "yes = True # Boolean variable\n", 49 | "print(type(yes))" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "Now using information from the previous lesson, combine different value types by printing a ```number``` and a ```string``` together. This is similar but instead of putting them in a variable, you are printing them to the screen. You'll have to change the value type for it to work like in the previous activity. Go back a lesson if you get stuck." 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": null, 62 | "metadata": {}, 63 | "outputs": [], 64 | "source": [ 65 | "print( + ) # Print a string and number together, correctly" 66 | ] 67 | }, 68 | { 69 | "cell_type": "markdown", 70 | "metadata": {}, 71 | "source": [ 72 | "You can even use two __variables__ in a ```print``` function by doing something like this ```print(var1 + var2)```. If you want more practice put different strings into the __variables__." 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": null, 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "var1 = 'Put something here'\n", 82 | "var2 = \" and put something here.\"\n", 83 | "print(var1 + var2) # Prints both" 84 | ] 85 | }, 86 | { 87 | "cell_type": "markdown", 88 | "metadata": {}, 89 | "source": [ 90 | "You can also use commas to seperate things when ```printing```. They will automatically put a **space** between the values, and it doesn't matter if they are *numbers, strings, or both*." 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": null, 96 | "metadata": {}, 97 | "outputs": [], 98 | "source": [ 99 | "var1 = \"You are cooking the egg at\"\n", 100 | "var2 = 45\n", 101 | "print(var1, var2, \"°C, cool down!\")" 102 | ] 103 | }, 104 | { 105 | "cell_type": "markdown", 106 | "metadata": {}, 107 | "source": [ 108 | "### Printing Equations\n", 109 | "\n", 110 | "![idea](https://apmonitor.com/che263/uploads/Begin_Python/idea.png)\n", 111 | "\n", 112 | "Jupyter Notebook automatically prints the last expression in a cell. One disadvatage of this feature is it only gives the result for the last line in the code. This method is mostly useful when you need to do a quick one line calculation. Run the code below and put in different equations to check your understanding." 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": null, 118 | "metadata": { 119 | "scrolled": true 120 | }, 121 | "outputs": [], 122 | "source": [ 123 | "5*2" 124 | ] 125 | }, 126 | { 127 | "cell_type": "markdown", 128 | "metadata": {}, 129 | "source": [ 130 | "The typical way in other Python modules is to simply put it in a ```print()``` function and you can get output for all lines." 131 | ] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": null, 136 | "metadata": {}, 137 | "outputs": [], 138 | "source": [ 139 | "print(14/2)\n", 140 | "print(7*2)\n", 141 | "print(3+11)" 142 | ] 143 | }, 144 | { 145 | "cell_type": "markdown", 146 | "metadata": {}, 147 | "source": [ 148 | "### Activity \n", 149 | "\n", 150 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 151 | "\n", 152 | "Make two __variables__ that will add two numbers when you print them together. This is kind of like the example above, but use numbers in your variables. " 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": null, 158 | "metadata": {}, 159 | "outputs": [], 160 | "source": [ 161 | " # First number variable\n", 162 | " # Second number variable\n", 163 | "print() # Print together" 164 | ] 165 | }, 166 | { 167 | "cell_type": "markdown", 168 | "metadata": {}, 169 | "source": [ 170 | "In lesson 3 it mentions variable properties. This was saying if you assign the same variable twice, it simply changes values.\n", 171 | "\n", 172 | "```python\n", 173 | "test = 3\n", 174 | "test = \"egg\"```\n", 175 | "\n", 176 | "Do the same here, except now print the variable in between variable assignments so you can see how it works." 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": null, 182 | "metadata": {}, 183 | "outputs": [], 184 | "source": [ 185 | "test = 3\n", 186 | " # print here\n", 187 | "test = \"egg\"\n", 188 | " # print here" 189 | ] 190 | }, 191 | { 192 | "cell_type": "markdown", 193 | "metadata": {}, 194 | "source": [ 195 | "Use the variable with an equation to ```print``` 500. You need to make the ```print()``` have an equation in order to change the output value." 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": null, 201 | "metadata": {}, 202 | "outputs": [], 203 | "source": [ 204 | "equation = 25*4\n", 205 | "print(equation ) # Make an equation to equal 500" 206 | ] 207 | } 208 | ], 209 | "metadata": { 210 | "kernelspec": { 211 | "display_name": "Python 3", 212 | "language": "python", 213 | "name": "python3" 214 | }, 215 | "language_info": { 216 | "codemirror_mode": { 217 | "name": "ipython", 218 | "version": 3 219 | }, 220 | "file_extension": ".py", 221 | "mimetype": "text/x-python", 222 | "name": "python", 223 | "nbconvert_exporter": "python", 224 | "pygments_lexer": "ipython3", 225 | "version": "3.7.4" 226 | } 227 | }, 228 | "nbformat": 4, 229 | "nbformat_minor": 2 230 | } 231 | -------------------------------------------------------------------------------- /05. Classes and Objects.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 5. Classes and Objects\n", 8 | "\n", 9 | "![list](https://apmonitor.com/che263/uploads/Begin_Python/list.png)\n", 10 | "\n", 11 | "Classes are collections of objects and functions. Many Python packages such as `time`, `tclab`, `numpy`, `scipy`, `gekko`, and others are distributed as `classes`. A class is imported with the `import` statement such as ```import time```.\n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=-rvIRWf7eGc&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Classes and Objects](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython05.png)](https://www.youtube.com/watch?v=-rvIRWf7eGc&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Classes and Objects\")\n", 16 | "\n", 17 | "Time is a package that has timing functions that we will use to pause the program for a specified amount of time. TCLab package has functions created with ```tclab.TCLab()```. The next lesson shows how to use the `tclab` functions." 18 | ] 19 | }, 20 | { 21 | "cell_type": "markdown", 22 | "metadata": {}, 23 | "source": [ 24 | "### Objects\n", 25 | "\n", 26 | "![parent_child](https://apmonitor.com/che263/uploads/Begin_Python/parent_child.png)\n", 27 | "\n", 28 | "Variables such as `int`, `float`, and `str` types are objects. Objects may also be created from a class template to create a new custom variable. You use a variable assignment to create an object, assigned to a name, such as ```lab = tclab.TCLab()```. This is called a parent (`tclab.TCLab()`) to child (`lab`) relationship because `lab` is created from the class `tclab`. The child object `lab` inherits all the functions of the parent. The child object is modified and customized in your code. You can give objects a name that you will remember and that are easy to type. For `tclab`, we prefer to use ```lab```, but it can be a different name. " 29 | ] 30 | }, 31 | { 32 | "cell_type": "markdown", 33 | "metadata": {}, 34 | "source": [ 35 | "#### Explanation of Objects\n", 36 | "```python\n", 37 | "lab = tclab.TCLab()\n", 38 | "```\n", 39 | "\n", 40 | "The first part of the expression is the child object name. For the Temperature Control Lab, we often use ```lab``` to as the name of our object. For something like your incubator, you could make an object to connect with it, called something like ```incubator```. \n", 41 | "\n", 42 | "The second part after ```=```, opens the installed package called ```tclab```. Then it looks for and uses ```TCLab``` to connect with your tclab. \n", 43 | "\n", 44 | "The ```.``` makes the program look for a sub-object, and the ```()``` tells python it is a function. This a function with no input arguments, because no value is put in the parentheses. Functions will be taught next lesson. \n", 45 | "\n", 46 | "So ```lab``` or whatever you decide to call it, is assigned to the programming already made found in the package:\n", 47 | "```python\n", 48 | "tclab.TCLab()```" 49 | ] 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "metadata": {}, 54 | "source": [ 55 | "### Try and Except\n", 56 | "\n", 57 | "![idea](https://apmonitor.com/che263/uploads/Begin_Python/idea.png)\n", 58 | "\n", 59 | "`Try` and `Except` methods can catch program errors. The program attempts to run the code under ```try```, and if it can't it runs the ```except``` section of the code. This is useful in a number of situations, such as importing packages you may not have installed and printing a message that something is wrong." 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": null, 65 | "metadata": {}, 66 | "outputs": [], 67 | "source": [ 68 | "try:\n", 69 | " print('Temperature = ' + 30)\n", 70 | "except:\n", 71 | " print('There is an error')" 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": {}, 77 | "source": [ 78 | "#### Install Temperature Control Lab\n", 79 | "\n", 80 | "This code will first ```try``` and import tclab. If it can't do that for some reason it uses ```except``` and installs the program that will let you use your Temperature Control Kit. Run the program to install TCLab. If installing TCLab is not working for you and the connection test below isn't working, try going [here](https://apmonitor.com/pdc/index.php/Main/ArduinoSetup) for additional instructions. If you want to install this package just for your user, not with admin privileges, keep the code ```--user``` in lines 6 and 8." 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "metadata": {}, 87 | "outputs": [], 88 | "source": [ 89 | "# install tclab\n", 90 | "try:\n", 91 | " import tclab\n", 92 | "except:\n", 93 | " # Needed to communicate through usb port\n", 94 | " !pip install --user pyserial\n", 95 | " # The --user is put in for accounts without admin privileges\n", 96 | " !pip install --user tclab \n", 97 | " # restart kernel if this doesn't import\n", 98 | " import tclab" 99 | ] 100 | }, 101 | { 102 | "cell_type": "markdown", 103 | "metadata": {}, 104 | "source": [ 105 | "#### Connection Test\n", 106 | "\n", 107 | "This object is what allows you to connect with the kit, read current temperatures, adjust heaters, or change the LED brightness. In the next lesson we will go over the basics of what this temperature control kit can really do. \n", 108 | "\n", 109 | "Plug in your TCLab if it's available. Now try running and the program will create the object from below. If the `tclab` package is installed and imported, it should connect, tell you additional information about your TCLab, then disconnect. If it doesn't work, or comes up with an error, go to the file __TCLab Help__.\n", 110 | "\n", 111 | "Don't worry if this is confusing, most of it will be explained in the next lesson." 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "execution_count": null, 117 | "metadata": {}, 118 | "outputs": [], 119 | "source": [ 120 | "import tclab # Imported Package\n", 121 | "lab = tclab.TCLab() # Object that connects with the kit\n", 122 | "lab.close() # Disconnects with the Lab" 123 | ] 124 | }, 125 | { 126 | "cell_type": "markdown", 127 | "metadata": {}, 128 | "source": [ 129 | "### Activity\n", 130 | "\n", 131 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 132 | "\n", 133 | "Connect the blue USB cable and plug in the white power cable to the power adapter. Run the TCLab exercise below that imports and tests the `TCLab` functions. Modify the name of the object from `lab` to `incubator` and add comments to the code. All these functions are covered in depth in lesson `6: Functions`. Don't worry if you don't understand each step of the program yet. Your task is to only change the name of the child object from `lab` to `incubator` and add comments such as `# this is a comment` to the code on the purpose of each section.\n", 134 | "\n", 135 | "![connections](https://apmonitor.com/che263/uploads/Begin_Python/connections.png)\n", 136 | "\n", 137 | "**TCLab Function Help**\n", 138 | "\n", 139 | "***Connect/Disconnect:*** ```lab = tclab.TCLab()``` Connect and create new lab object, ```lab.close()``` disconnects lab.\n", 140 | "\n", 141 | "***LED:*** ```lab.LED()``` Percentage of output light for __Hot__ Light.\n", 142 | "\n", 143 | "***Heaters:*** ```lab.Q1()``` and ```lab.Q2()``` Percentage of power to heaters (0-100).\n", 144 | "\n", 145 | "***Temperatures:*** ```lab.T1``` and ```lab.T2``` Value of current heater temperatures." 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": null, 151 | "metadata": {}, 152 | "outputs": [], 153 | "source": [ 154 | "import tclab\n", 155 | "import time\n", 156 | "\n", 157 | "lab = tclab.TCLab()\n", 158 | "\n", 159 | "print('Turn on heaters and LED for 20 seconds')\n", 160 | "lab.Q1(50)\n", 161 | "lab.Q2(50)\n", 162 | "lab.LED(50)\n", 163 | "\n", 164 | "for i in range(21):\n", 165 | " print('Time:',i,'T1:',lab.T1,'T2:',lab.T2)\n", 166 | " time.sleep(1)\n", 167 | " \n", 168 | "lab.Q1(0); lab.Q2(0); lab.LED(0)\n", 169 | "lab.close()" 170 | ] 171 | } 172 | ], 173 | "metadata": { 174 | "kernelspec": { 175 | "display_name": "Python 3", 176 | "language": "python", 177 | "name": "python3" 178 | }, 179 | "language_info": { 180 | "codemirror_mode": { 181 | "name": "ipython", 182 | "version": 3 183 | }, 184 | "file_extension": ".py", 185 | "mimetype": "text/x-python", 186 | "name": "python", 187 | "nbconvert_exporter": "python", 188 | "pygments_lexer": "ipython3", 189 | "version": "3.7.4" 190 | } 191 | }, 192 | "nbformat": 4, 193 | "nbformat_minor": 2 194 | } 195 | -------------------------------------------------------------------------------- /06. Functions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 6. Functions\n", 8 | "\n", 9 | "![list](https://apmonitor.com/che263/uploads/Begin_Python/list.png)\n", 10 | "\n", 11 | "Functions create modular code that can do the same task repeatedly without you having to type out the same code each time. Functions make complex code accessible with a single statement. You also can create your own function, but there are also some are built in to Python or in many packages. One built in function you have already seen is the ```print()``` function.\n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=dP3e2jIHqXw&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Functions](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython06.png)](https://www.youtube.com/watch?v=dP3e2jIHqXw&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Functions\")\n", 16 | "\n", 17 | "For the incubation example, a display function could be used such as the function `ctemp()` to print the current temperature. This re-uses the print statement so that you don't need to type it out each time for temperatures 1 and 2.\n", 18 | "\n", 19 | "```python\n", 20 | "# create the function\n", 21 | "def ctemp(temperature):\n", 22 | " print('Current temperature: ' + str(temperature) + '°C')\n", 23 | " return\n", 24 | "\n", 25 | "# use the function twice\n", 26 | "ctemp(20.51)\n", 27 | "ctemp(22.57)\n", 28 | "```\n", 29 | "\n", 30 | "This prints the two temperatures as:\n", 31 | "\n", 32 | "```\n", 33 | "Current temperature: 20.51°C\n", 34 | "Current temperature: 22.57°C\n", 35 | "```" 36 | ] 37 | }, 38 | { 39 | "cell_type": "markdown", 40 | "metadata": {}, 41 | "source": [ 42 | "### Creating a custom function\n", 43 | "\n", 44 | "![idea](https://apmonitor.com/che263/uploads/Begin_Python/idea.png)\n", 45 | "\n", 46 | "The way to tell the computer you are starting your own function is ```def``` followed by the function name. You need the ```():``` for the computer to recognize it as a function. \n", 47 | "\n", 48 | "```python\n", 49 | "def myFunction(): # Defining the Function\n", 50 | "```" 51 | ] 52 | }, 53 | { 54 | "cell_type": "markdown", 55 | "metadata": {}, 56 | "source": [ 57 | "The code is then added into the function scope. Once the function code is complete, you need to call the function for it to run that code. The way you do that is the function name with ```()``` as `myFunction()`." 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": null, 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [ 66 | "def myFunction(): # Defining the Function\n", 67 | " print(\"Function\")\n", 68 | " \n", 69 | "myFunction() # Calling the Function" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "metadata": {}, 75 | "source": [ 76 | "You can also put in values in the ```()``` as inputs for the function. Sometimes a function needs multiple inputs and those can be separated with commas. You should also use the ```return``` statement that gives back results from `myFunction()`.\n", 77 | "\n", 78 | "This is a confusing concept, and if you need more help with it, play around with the code below or research information about Python functions online." 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": null, 84 | "metadata": {}, 85 | "outputs": [], 86 | "source": [ 87 | "def myFunction(a, b): \n", 88 | " return a*b # Gives the multiplied value back to be output\n", 89 | "\n", 90 | "myFunction(3, 4) # Enters 3 into a and 4 into b" 91 | ] 92 | }, 93 | { 94 | "cell_type": "markdown", 95 | "metadata": {}, 96 | "source": [ 97 | "### Activity\n", 98 | "\n", 99 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 100 | "\n", 101 | "Make a function that adds two values together, you can choose the two values or make them an user input. Use the example above for help if you need it." 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": null, 107 | "metadata": {}, 108 | "outputs": [], 109 | "source": [ 110 | "def adding():\n", 111 | " #Code\n", 112 | " \n", 113 | "adding()" 114 | ] 115 | }, 116 | { 117 | "cell_type": "markdown", 118 | "metadata": {}, 119 | "source": [ 120 | "### TCLab Functions\n", 121 | "\n", 122 | "![connections](https://apmonitor.com/che263/uploads/Begin_Python/connections.png)\n", 123 | "\n", 124 | "In the last lesson on objects, it mentioned the ```lab``` object. Objects can have functions that are used with a ```.``` and then the function name. Functions can change things on the TCLab such as __light brightness__, __heater power__, and get __temperatures__.\n", 125 | "\n", 126 | "***LED***\n", 127 | "\n", 128 | "```lab.LED()``` This function sets the LED power, that is labeled __Hot__, on your tclab turn on at a certain brightness. If you want the light brightest use ```lab.LED(100)``` and ```lab.LED(0)``` to turn the LED off.\n", 129 | "\n", 130 | "***Heaters***\n", 131 | "\n", 132 | "```lab.Q1()``` or ```lab.Q2()``` sets the power percentage of heater one or two. Same as the ```LED``` function, ```Q1``` is set highest at ```lab.Q1(100)``` and off at ```lab.Q1(0)```. The other heater works the same way, ```Q2``` is set highest at ```lab.Q2(100)``` and off at ```lab.Q2(0)```\n", 133 | "\n", 134 | "***Temperatures***\n", 135 | "\n", 136 | "```lab.T1``` or ```lab.T2``` gives the current reading of the temperature for the first or second heater. It gives the values in __Celsius__.\n", 137 | "\n", 138 | "***Disconnecting***\n", 139 | "\n", 140 | "We also use ```lab.close()``` at the end of the program to disconnect the kit to make sure it doesn't keep the heaters on. This function does _not_ turn off the LED, however." 141 | ] 142 | }, 143 | { 144 | "cell_type": "markdown", 145 | "metadata": {}, 146 | "source": [ 147 | "### Activity\n", 148 | "\n", 149 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 150 | "\n", 151 | "Use the LED at 70% and then turn it off after 10 seconds. " 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": null, 157 | "metadata": {}, 158 | "outputs": [], 159 | "source": [ 160 | "import tclab\n", 161 | "import time \n", 162 | "\n", 163 | "lab = tclab.TCLab() # Creates object: lab\n", 164 | "\n", 165 | "lab.LED('Put your percent here') # Light Power Percentage\n", 166 | "time.sleep(\"How long you want it to turn on\") # Program Waits\n", 167 | "lab.LED(0) # Light Turned off\n", 168 | "\n", 169 | "lab.close() # Disconnects Kit" 170 | ] 171 | }, 172 | { 173 | "cell_type": "markdown", 174 | "metadata": {}, 175 | "source": [ 176 | "Use heater one, ```lab.Q1```, at 40 percent and heater two, ```lab.Q2```, at 80 percent. Use ```print()``` to record the temperatures with ```lab.T1``` and ```lab.T2``` after 10 seconds, with ```time.sleep()```. Make sure to disconnect the heaters after you record the temperatures. Use the LED activity and the discriptions above if you don't remember some of the functions. If the heaters don't turn off because of a bug in your code, unplug the cables connected to the lab to stop the heaters or restart the kernel to run the lab again. If you get errors when you run your code, check out the __TCLab Help__ IPython notebook for common errors or search the [Frequently Asked Questions for Troubleshooting](https://apmonitor.com/pdc/index.php/Main/ArduinoSetup). You can also read the error descriptions Jupyter gives you below your code to diagnose the problem." 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": null, 182 | "metadata": {}, 183 | "outputs": [], 184 | "source": [] 185 | } 186 | ], 187 | "metadata": { 188 | "kernelspec": { 189 | "display_name": "Python 3", 190 | "language": "python", 191 | "name": "python3" 192 | }, 193 | "language_info": { 194 | "codemirror_mode": { 195 | "name": "ipython", 196 | "version": 3 197 | }, 198 | "file_extension": ".py", 199 | "mimetype": "text/x-python", 200 | "name": "python", 201 | "nbconvert_exporter": "python", 202 | "pygments_lexer": "ipython3", 203 | "version": "3.7.4" 204 | } 205 | }, 206 | "nbformat": 4, 207 | "nbformat_minor": 2 208 | } 209 | -------------------------------------------------------------------------------- /07. Loops.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 7. Loops\n", 8 | "\n", 9 | "![list](https://apmonitor.com/che263/uploads/Begin_Python/list.png)\n", 10 | "\n", 11 | "There are two basic types of loops including `for` and `while`. An example of a loop is to check the temperature of the egg every second and adjust the heater.\n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=qR0njzQvvOA&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Loops](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython07.png)](https://www.youtube.com/watch?v=qR0njzQvvOA&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Loops\")\n", 16 | "\n", 17 | "### While Loops\n", 18 | "\n", 19 | "![idea](https://apmonitor.com/che263/uploads/Begin_Python/idea.png)\n", 20 | "\n", 21 | "While loops work by repeating until the condition becomes ```False```. The way they are coded can almost be said as a sentence. ```while x > 0:``` While x is greater than 0.\n", 22 | "\n", 23 | "While loops can get stuck in an infinite loop if the condition for termination is never met. You can stop the infinite loop by setting the value of ```True``` to become ```False``` in different ways. In the code below, the infinite loop is broken by making ```x``` one less each time it goes through the loop, with ```x = x - 1```. \n", 24 | "\n", 25 | "See how the loop changes by switching the value of ```x```." 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": null, 31 | "metadata": { 32 | "scrolled": true 33 | }, 34 | "outputs": [], 35 | "source": [ 36 | "print('Are you done yet?')\n", 37 | "\n", 38 | "x = 8 # Switch this number\n", 39 | "\n", 40 | "while x >= 5: # Code stops when x is less than or equal to 5\n", 41 | " print(\"Almost done \" + str(x)) # Uses the value in the loop and changes it to a string\n", 42 | " x = x - 1 # Makes x one less each loop " 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "Tip: ```x = x - 1``` can be simplified into ```x -= 1```. They mean the same thing, it's just a little shorter. This is true for most other math operators. ```+=```, ```*=```, ```/=```, are all working equations." 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": null, 55 | "metadata": {}, 56 | "outputs": [], 57 | "source": [ 58 | "x = 5\n", 59 | "x *= 3\n", 60 | "print(x)" 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": {}, 66 | "source": [ 67 | "Another thing used in `while` loops is comparitive statements such as ```==``` symbols. Just one ```=``` means you are assigning a variable, but this shouldn't be done to check ```while``` loop conditions. Instead use the ```==``` to tell the `while` loop that you are just comparing the two values. For example:\n", 68 | "\n", 69 | "```python\n", 70 | "while x == 0:\n", 71 | "```" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": null, 77 | "metadata": {}, 78 | "outputs": [], 79 | "source": [ 80 | "x = 0\n", 81 | "\n", 82 | "while x == 0:\n", 83 | " print('First While Loop')\n", 84 | " print(x)\n", 85 | " x += 1\n", 86 | " while x == 1:\n", 87 | " print('Second (Nested) While Loop')\n", 88 | " print(x)\n", 89 | " x += 1\n", 90 | "print('Third While Loop')\n", 91 | "while x <= 5:\n", 92 | " print(x)\n", 93 | " x += 1" 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "metadata": {}, 99 | "source": [ 100 | "### For Loops\n", 101 | "\n", 102 | "![exercise](https://apmonitor.com/che263/uploads/Begin_Python/exercise.png)\n", 103 | "\n", 104 | "A `for` loop is needed when you know how many times the loop should cycle. A `while` loop is typically used when the number of cycles is unknown beforehand. A `for` loop is formatted ```for i in ```[1,2,3]```:```. The ```i``` is just a typical iterator. You can enter any variable name you like instead of `i`. The ```i```, is used to keep track of the current loop count. The ```in``` is saying what values the `for` loop iterates through, and the ```[1,2,3]``` is a list of the values that the `for` loop will use.\n", 105 | "\n", 106 | "You can enter a number of things besides the `[1,2,3]` to define the loop, and we'll go over those below. You can practice `for` loops by putting new values into that spot such as a list or range operator." 107 | ] 108 | }, 109 | { 110 | "cell_type": "markdown", 111 | "metadata": {}, 112 | "source": [ 113 | "#### Range\n", 114 | "One thing that can go in for loops is `range`. It's formatted as ```range()```, and the number is in the ```()``` is how many times it repeats. See what `range` does differently by putting in a different number. " 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": null, 120 | "metadata": {}, 121 | "outputs": [], 122 | "source": [ 123 | "for i in range(7): # Enter a new number\n", 124 | " print('Cycle', i)" 125 | ] 126 | }, 127 | { 128 | "cell_type": "markdown", 129 | "metadata": {}, 130 | "source": [ 131 | "Range can have up to 3 numbers if you need more control. The __first__ is the starting number, the __second__ is the ending number, and the __third__ is what steps it will take. It looks something like this: \n", 132 | "```python\n", 133 | "for i in range(0,8,3):\n", 134 | "```\n", 135 | "If you only put one value into a ```range()``` it will assume it is the __second__ number. So the example you did above, ```for i in range(7):```, really looks like this:\n", 136 | "```python\n", 137 | "for i in range(0,7,1):\n", 138 | "```\n", 139 | "Practice this concept by changing the numbers. Make the stepping number negative, but the first number bigger than the second. This should make the loop count __backwards__." 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": null, 145 | "metadata": {}, 146 | "outputs": [], 147 | "source": [ 148 | "for i in range(0,8,3): # Enter new numbers, then enter 8,0,-3\n", 149 | " print('Cycle', i)" 150 | ] 151 | }, 152 | { 153 | "cell_type": "markdown", 154 | "metadata": {}, 155 | "source": [ 156 | "#### String\n", 157 | "If you enter a string, like ```\"hello\"``` it will loop however many characters are in the string. Enter any new word you like." 158 | ] 159 | }, 160 | { 161 | "cell_type": "code", 162 | "execution_count": null, 163 | "metadata": {}, 164 | "outputs": [], 165 | "source": [ 166 | "for i in \"hello\": # Loops for number of characters, practice by entering a new word\n", 167 | " print('Cycle', i)" 168 | ] 169 | }, 170 | { 171 | "cell_type": "markdown", 172 | "metadata": {}, 173 | "source": [ 174 | "#### Variable\n", 175 | "You can also enter a variable to control the number of `for` loop cycles. The variable is used in the `for` loop to determine the number of cycles. The variable can be numbers, strings, or a list. Using ```for i in range(9):``` is the same as ```x = 9``` ```for i in range(x):```." 176 | ] 177 | }, 178 | { 179 | "cell_type": "code", 180 | "execution_count": null, 181 | "metadata": {}, 182 | "outputs": [], 183 | "source": [ 184 | "x = \"chicken\"\n", 185 | "for i in x:\n", 186 | " print(i)\n", 187 | "\n", 188 | "y = 9\n", 189 | "for i in range(y):\n", 190 | " print(i)" 191 | ] 192 | }, 193 | { 194 | "cell_type": "markdown", 195 | "metadata": {}, 196 | "source": [ 197 | "#### Using ```i```\n", 198 | "Now here's the twist. In a `for` loop the ```i``` variable, in ```for i in ```(variable, range, string)```:```, can be used during the repeating loop. Everytime the `for` loop repeats again, it goes to the next value, and assigns it to `i`. You can use `i` in a loop to do different things based on the cycle number. \n", 199 | "\n", 200 | "This is similar to the ```while``` loop example where we used this code \n", 201 | "```python\n", 202 | "print(\"Almost done \" + str(x))```\n", 203 | "\n", 204 | "For numbers, ```for loops``` start counting at `0`. If the loop had a ```range(3)```, it would count 0, 1, 2. For strings, it just prints the individual characters in order so ```\"hi\"``` would just output __h__ then __i__. This can be used in a number of useful ways you may use later in this course. Now using stepping in range, we can print numbers in steps." 205 | ] 206 | }, 207 | { 208 | "cell_type": "code", 209 | "execution_count": null, 210 | "metadata": {}, 211 | "outputs": [], 212 | "source": [ 213 | "for i in 'cheese':\n", 214 | " print(i)\n", 215 | "\n", 216 | "print(\" \") # Just to space it out, same for the 2 other print lines below\n", 217 | " \n", 218 | "for i in range(5):\n", 219 | " print(i)\n", 220 | "print(\" \")\n", 221 | "\n", 222 | "for i in range(0,10,2): # See the explanation in the range section above if this is confusing\n", 223 | " print(i)\n", 224 | "print(' ')\n", 225 | "\n", 226 | "for i in range(10,0,-2): # Backwards version of the loop above\n", 227 | " print(i)" 228 | ] 229 | }, 230 | { 231 | "cell_type": "markdown", 232 | "metadata": {}, 233 | "source": [ 234 | "### Activity\n", 235 | "\n", 236 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 237 | "\n", 238 | "Create a ```for``` loop that prints out each letter of your name, __backwards__.\n", 239 | "\n", 240 | "```python\n", 241 | "string[number]\n", 242 | "``` \n", 243 | "\n", 244 | "This function finds the index of a string. ```\"hi\"[0]``` would be ```\"h\"``` and ```\"hi\"[1]``` would be ```\"i\"```.\n", 245 | "\n", 246 | "```python\n", 247 | "len(string)\n", 248 | "```\n", 249 | "\n", 250 | "This function gives the length of a string. ```len(\"waffles\")``` would be ```7```." 251 | ] 252 | }, 253 | { 254 | "cell_type": "code", 255 | "execution_count": null, 256 | "metadata": {}, 257 | "outputs": [], 258 | "source": [ 259 | "name = \"enter your name\"\n", 260 | "\n", 261 | "for i in range((len(name) - 1), \"end value\", \"step backwards\"): # Remember that python starts at 0 for indexing\n", 262 | " print(name[i]) # Brackets [] refer to the index of a string" 263 | ] 264 | }, 265 | { 266 | "cell_type": "markdown", 267 | "metadata": {}, 268 | "source": [ 269 | "When you run code that turns on the heaters, make sure they work by putting your hand over them or observing the thermochromic paint turn pink when they are over 37°C. Go over Lesson 6 Functions TCLab again, if you don't remember them.\n", 270 | "\n", 271 | "Make a `while` loop that blinks on and off the __Hot__ LED light. If the temperature gets above 28°C, then turn on the light on, disconnect the lab after 3 seconds. You don't need to install `tclab` again once it is installed the first time, just use ```import tclab```. It's also useful to print the temperature to see if the program works and the temperature is changing." 272 | ] 273 | }, 274 | { 275 | "cell_type": "code", 276 | "execution_count": null, 277 | "metadata": {}, 278 | "outputs": [], 279 | "source": [ 280 | "import tclab # Imports usually come first\n", 281 | "import time\n", 282 | "lab = tclab.TCLab()\n", 283 | "\n", 284 | "# Set both heater powers on before the while loop\n", 285 | "\n", 286 | "# Make a while loop" 287 | ] 288 | }, 289 | { 290 | "cell_type": "markdown", 291 | "metadata": {}, 292 | "source": [ 293 | "Make a `for` loop that makes the LED percent go all the way from 100 to 0 in steps of 1. Include a 0.1 second pause in between each step with `time.sleep(0.1)`." 294 | ] 295 | }, 296 | { 297 | "cell_type": "code", 298 | "execution_count": null, 299 | "metadata": {}, 300 | "outputs": [], 301 | "source": [ 302 | "import tclab\n", 303 | "import time\n", 304 | "\n", 305 | "for i in range(): # Needs to go from 100 to 0\n", 306 | " time.sleep(0.1)" 307 | ] 308 | } 309 | ], 310 | "metadata": { 311 | "kernelspec": { 312 | "display_name": "Python 3", 313 | "language": "python", 314 | "name": "python3" 315 | }, 316 | "language_info": { 317 | "codemirror_mode": { 318 | "name": "ipython", 319 | "version": 3 320 | }, 321 | "file_extension": ".py", 322 | "mimetype": "text/x-python", 323 | "name": "python", 324 | "nbconvert_exporter": "python", 325 | "pygments_lexer": "ipython3", 326 | "version": "3.7.4" 327 | } 328 | }, 329 | "nbformat": 4, 330 | "nbformat_minor": 2 331 | } 332 | -------------------------------------------------------------------------------- /08. Input.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 8. Input\n", 8 | "\n", 9 | "![list](https://apmonitor.com/che263/uploads/Begin_Python/list.png)\n", 10 | "\n", 11 | "Input simply requests information from the person using the computer. By default the input value is stored as a __string__ so if you're doing a math equation you need to turn it into an __integer__ or __float__. In an egg temperature controller, certain types of eggs may require a different input and you could put that in your code to change the desired temperature. You could also use `input` to manually change power to the heaters.\n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=63P8tLh-j5o&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Input](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython08.png)](https://www.youtube.com/watch?v=63P8tLh-j5o&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Input\")\n", 16 | "\n", 17 | "If you run the code below, it asks you for a number, then comes up as an error. You need to turn ```eggs``` __variable__ into an __int__. \n", 18 | "\n", 19 | "Use ```int()``` and ```str()``` to change types.\n", 20 | "(Reference the bottom of the **variables lesson**, if you get stuck)\n", 21 | "\n", 22 | "![incubator](https://apmonitor.com/che263/uploads/Begin_Python/incubator.png)" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "metadata": {}, 29 | "outputs": [], 30 | "source": [ 31 | "eggs = input(\"How many eggs do you have? \")\n", 32 | "\n", 33 | "# Change eggs into an integer\n", 34 | "\n", 35 | "eggs = eggs - 2\n", 36 | "\n", 37 | "print(\"Your hatchlings are \" + (eggs) + ' because two are still developing') # Change eggs back to a string" 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "metadata": {}, 43 | "source": [ 44 | "You can also make the input change into an __int__ on the same line as the input." 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": { 51 | "scrolled": true 52 | }, 53 | "outputs": [], 54 | "source": [ 55 | "number = int(input('Enter a number: '))\n", 56 | "\n", 57 | "print(number + 5)" 58 | ] 59 | }, 60 | { 61 | "cell_type": "markdown", 62 | "metadata": {}, 63 | "source": [ 64 | "### Activity\n", 65 | "\n", 66 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 67 | "\n", 68 | "Make a function that uses `input` for two values. The function should take two values, add the second number to the first number 20 times, then return the new value. Make sure to use a ```for``` loop in your function. Go back to the lesson on **Loops** or **Functions** if you get stuck." 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": null, 74 | "metadata": {}, 75 | "outputs": [], 76 | "source": [ 77 | "# Define a function\n", 78 | " # Use a for loop\n", 79 | "\n", 80 | "print() # Call the function" 81 | ] 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "metadata": {}, 86 | "source": [ 87 | "Use a ```while``` loop to keep asking the user for input for the __Hot__ light power percentage. Make the code so if the entered value is 0, the program stops.\n", 88 | "\n", 89 | "(This is similar to something used in a real incubator, you could keep turning it to different temperatures, or turn off the system completely)" 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": null, 95 | "metadata": {}, 96 | "outputs": [], 97 | "source": [ 98 | "import tclab\n" 99 | ] 100 | } 101 | ], 102 | "metadata": { 103 | "kernelspec": { 104 | "display_name": "Python 3", 105 | "language": "python", 106 | "name": "python3" 107 | }, 108 | "language_info": { 109 | "codemirror_mode": { 110 | "name": "ipython", 111 | "version": 3 112 | }, 113 | "file_extension": ".py", 114 | "mimetype": "text/x-python", 115 | "name": "python", 116 | "nbconvert_exporter": "python", 117 | "pygments_lexer": "ipython3", 118 | "version": "3.7.4" 119 | } 120 | }, 121 | "nbformat": 4, 122 | "nbformat_minor": 2 123 | } 124 | -------------------------------------------------------------------------------- /09. If Statements.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 9. ```if``` Statements\n", 8 | "\n", 9 | "![list](https://apmonitor.com/che263/uploads/Begin_Python/list.png)\n", 10 | "\n", 11 | "If and else statements tell the computer what to do based on a `True` condition.\n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=aNB2MQecPNk&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Conditionals: if](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython09.png)](https://www.youtube.com/watch?v=aNB2MQecPNk&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Conditionals: if\")\n", 16 | "\n", 17 | "This could be used for the temperature of the egg by telling the heaters to turn on, if the egg is too cold.\n", 18 | "\n", 19 | "![hatch](https://apmonitor.com/che263/uploads/Begin_Python/hatch.png)\n", 20 | "\n", 21 | "### ```if```\n", 22 | "```if``` is a certain condition, in this case ```if``` the number is greater than 21, it will print something. Practice using ```if``` by running the code and putting in a value _more_ than 21." 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "metadata": {}, 29 | "outputs": [], 30 | "source": [ 31 | "days = int(input(\"Enter how long the egg has been in the incubator \"))\n", 32 | "\n", 33 | "if days < 21: # Print if days is less than 21 days\n", 34 | " print(\"The chick is still developing\")" 35 | ] 36 | }, 37 | { 38 | "cell_type": "markdown", 39 | "metadata": {}, 40 | "source": [ 41 | "### ```else```\n", 42 | "Else statements will execute code if no ```if``` statements are executed. Check your understanding by running the code and putting in a value _less_ than 21." 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": null, 48 | "metadata": {}, 49 | "outputs": [], 50 | "source": [ 51 | "days = int(input(\"Enter the days \"))\n", 52 | "\n", 53 | "if days > 21:\n", 54 | " print(\"Chick should have hatched out of egg\") \n", 55 | "\n", 56 | "else:\n", 57 | " print(\"The chick is still developing\")" 58 | ] 59 | }, 60 | { 61 | "cell_type": "markdown", 62 | "metadata": {}, 63 | "source": [ 64 | "**Make your own `if` statement**\n", 65 | "\n", 66 | "Practice `if` statements by making your own `if` and `else` statement using user input, with your own idea. Make sure it prints something when it is done." 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": null, 72 | "metadata": {}, 73 | "outputs": [], 74 | "source": [] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "## elif\n", 81 | "```elif```, or else if, statements are a continued if statement. When the first condition isn't true, it will go down to the next ```elif``` and so on. You can have as many ```elif``` statements as you need. Check your understanding by using the right input value to get ```elif``` statement to run." 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": null, 87 | "metadata": {}, 88 | "outputs": [], 89 | "source": [ 90 | "days = int(input('Enter days '))\n", 91 | "\n", 92 | "if days > 21:\n", 93 | " print('Chick should have hatched out of egg')\n", 94 | " \n", 95 | "elif days > 18:\n", 96 | " print('Chick should hatch soon')\n", 97 | "\n", 98 | "else: # Executes only when everything else doesn't work\n", 99 | " print('The chick is still developing')" 100 | ] 101 | }, 102 | { 103 | "cell_type": "markdown", 104 | "metadata": {}, 105 | "source": [ 106 | "You can also have an ```if``` statement inside another ```if``` statement. You can also use the __comparative__ statements from the _Python Basic Knowledge_. These include things like ```and```, ```or```, and lots more. Go to that file if you want to see common ones and what they do. Practice modifying the code to what you like and add other ```if``` statements for the missing days." 107 | ] 108 | }, 109 | { 110 | "cell_type": "code", 111 | "execution_count": null, 112 | "metadata": {}, 113 | "outputs": [], 114 | "source": [ 115 | "x = int(input(\"How long has the egg been in the incubator? \"))\n", 116 | "\n", 117 | "if x < 21 and x > 18:\n", 118 | " print('Chick should hatch soon')\n", 119 | "\n", 120 | "elif x >= 21:\n", 121 | " if x > 25:\n", 122 | " print(\"Chick probably won't hatch\")\n", 123 | " else:\n", 124 | " print('Chick should have hatched out of egg')\n", 125 | "\n", 126 | "else:\n", 127 | " print('The chick is still developing')" 128 | ] 129 | }, 130 | { 131 | "cell_type": "markdown", 132 | "metadata": {}, 133 | "source": [ 134 | "### Activity\n", 135 | "\n", 136 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 137 | "\n", 138 | "Use ```if``` and ```elif``` statements to create a calculator using basic operators. Have the user input two values to be operated on. Have an option to use addition, subtraction, multiplication, and division on those two numbers. Make sure you print the finished answer. " 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": null, 144 | "metadata": {}, 145 | "outputs": [], 146 | "source": [ 147 | "x = float(input(\"Enter your first value: \"))\n", 148 | "y = float(input(\"Enter your second value: \"))" 149 | ] 150 | }, 151 | { 152 | "cell_type": "markdown", 153 | "metadata": {}, 154 | "source": [ 155 | "Use ```if``` statements in a ```while``` loop. Create code that turns on the __LED__ when the temperature goes above 30°C, and disconnects the kit and turns off the __LED__ when the temperature goes above 35°C, and output the temperature every time the program loops. Set the heater powers with user ```input```. " 156 | ] 157 | }, 158 | { 159 | "cell_type": "code", 160 | "execution_count": null, 161 | "metadata": {}, 162 | "outputs": [], 163 | "source": [ 164 | "import tclab\n", 165 | "lab = tclab.TCLab()\n", 166 | "\n", 167 | "#while temp < 35\n", 168 | " #if temp < 30\n", 169 | "\n", 170 | "lab.close()" 171 | ] 172 | }, 173 | { 174 | "cell_type": "markdown", 175 | "metadata": {}, 176 | "source": [ 177 | "Make a guessing game that makes a random LED percent and the user has to type inputs to guess it. Make the program say higher or lower depending on the guess. When the guess is correct, flash the LED for a few seconds and disconnect.\n", 178 | "\n", 179 | "You can use ```while``` loops, ```for``` loops, ```if``` and ```else``` statements, ```input```, ```print```. Use any combination to create the program." 180 | ] 181 | }, 182 | { 183 | "cell_type": "code", 184 | "execution_count": null, 185 | "metadata": {}, 186 | "outputs": [], 187 | "source": [ 188 | "import random # You need this for the random LED percent\n", 189 | "\n", 190 | "randomLED = random.randint(1,101) # This makes a random value between 1 and 100\n", 191 | "\n", 192 | "import tclab\n", 193 | "import time\n" 194 | ] 195 | } 196 | ], 197 | "metadata": { 198 | "kernelspec": { 199 | "display_name": "Python 3", 200 | "language": "python", 201 | "name": "python3" 202 | }, 203 | "language_info": { 204 | "codemirror_mode": { 205 | "name": "ipython", 206 | "version": 3 207 | }, 208 | "file_extension": ".py", 209 | "mimetype": "text/x-python", 210 | "name": "python", 211 | "nbconvert_exporter": "python", 212 | "pygments_lexer": "ipython3", 213 | "version": "3.7.4" 214 | } 215 | }, 216 | "nbformat": 4, 217 | "nbformat_minor": 2 218 | } 219 | -------------------------------------------------------------------------------- /10. Lists and Tuples.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 10. Lists\n", 8 | "\n", 9 | "![list](https://apmonitor.com/che263/uploads/Begin_Python/list.png)\n", 10 | "\n", 11 | "Lists are a way of storing a sequence of values and possibly different types of information in just one __variable__.\n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=1CPP8aB-8WU&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Lists and Tuples](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython10.png)](https://www.youtube.com/watch?v=1CPP8aB-8WU&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Lists and Tuples\")\n", 16 | "\n", 17 | "This is shown below, by using brackets \\[ ]. You could use lists, for an incubator, to keep information on which chickens are in different eggs. You could also use them to store a previous temperature of the incubator.\n", 18 | "\n", 19 | "![chickens](https://apmonitor.com/che263/uploads/Begin_Python/chickens.png)" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": null, 25 | "metadata": {}, 26 | "outputs": [], 27 | "source": [ 28 | "chickens = [\"Leghorn\", 'Barnevelder', 'Plymouth Rock', 23, False]\n", 29 | "print(chickens)" 30 | ] 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "metadata": {}, 35 | "source": [ 36 | "You can also have a list in a list." 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "metadata": {}, 43 | "outputs": [], 44 | "source": [ 45 | "chickens = ['Leghorn', [True, 42],'Barnevelder', \"Plymouth Rock\"]\n", 46 | "print(chickens)" 47 | ] 48 | }, 49 | { 50 | "cell_type": "markdown", 51 | "metadata": {}, 52 | "source": [ 53 | "You can change one of the values in a list or print just one value. Remember how ```for``` loops start at `0`? A list index also starts at `0`." 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": null, 59 | "metadata": {}, 60 | "outputs": [], 61 | "source": [ 62 | "chickens = ['Leghorn', \"Barnevelder\", 'Plymouth Rock']\n", 63 | "chickens[0] = 'Ancona' # Replaces Leghorn with Ancona\n", 64 | "del chickens[1] # Deletes the second value\n", 65 | "print(chickens)\n", 66 | "print(chickens[1])" 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": {}, 72 | "source": [ 73 | "You can also use a list to iterate with a ```for``` loop." 74 | ] 75 | }, 76 | { 77 | "cell_type": "code", 78 | "execution_count": null, 79 | "metadata": {}, 80 | "outputs": [], 81 | "source": [ 82 | "chickens = [\"Leghorn\", 'Barnevelder', 'Plymouth Rock']\n", 83 | "\n", 84 | "for i in chickens:\n", 85 | " print(i)" 86 | ] 87 | }, 88 | { 89 | "cell_type": "markdown", 90 | "metadata": {}, 91 | "source": [ 92 | "You can even do a `for` loop of a list with `if` statements inside.\n", 93 | "\n", 94 | "(The == symbol is comparing two values. If they are the same it will be ```True```.)" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": null, 100 | "metadata": {}, 101 | "outputs": [], 102 | "source": [ 103 | "chickens = [\"Leghorn\", 'Barnevelder', 'Plymouth Rock']\n", 104 | "\n", 105 | "for i in chickens:\n", 106 | " if i == 'Leghorn':\n", 107 | " print(\"Ancona\")\n", 108 | " else:\n", 109 | " print(i)" 110 | ] 111 | }, 112 | { 113 | "cell_type": "markdown", 114 | "metadata": {}, 115 | "source": [ 116 | "**Useful List Functions**\n", 117 | "\n", 118 | "There are many more ways to use lists than these examples and all of them are online. Some of these include ```listName.append()```, ```listName.extend()```, and much more. Run this code to see what the ```.append()``` function does." 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "execution_count": null, 124 | "metadata": {}, 125 | "outputs": [], 126 | "source": [ 127 | "myList = [\"yes\", \"no\"]\n", 128 | "\n", 129 | "myList.append(\"maybe\")\n", 130 | "\n", 131 | "print(myList)" 132 | ] 133 | }, 134 | { 135 | "cell_type": "markdown", 136 | "metadata": {}, 137 | "source": [ 138 | "**Assigning New Values**\n", 139 | "\n", 140 | "After you get all of your data points in a list, one way to execute the same equation to all values in a list is shown below. This can be very useful, for example if you wanted to turn your data points from Celcius to Fahrenheit. The example below shows a way to convert a whole list of values from Celcius to Fahrenheit." 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": null, 146 | "metadata": {}, 147 | "outputs": [], 148 | "source": [ 149 | "data_celsius = [24, 21, 26, 30, 20] # List of Celsius temperature values\n", 150 | "\n", 151 | "data_fahrenheit = [i*(9/5) + 32 for i in data_celsius] # This converts to Fahrenheit\n", 152 | "\n", 153 | "formatted_data = [\"%.2f\" % i for i in data_fahrenheit] # This formats the data points to 2 decimal places\n", 154 | "\n", 155 | "print(formatted_data)\n", 156 | "\n", 157 | "for i in data_fahrenheit:\n", 158 | " print(\"%.1f\" % i) # Prints out each data point to 1 decimal place" 159 | ] 160 | }, 161 | { 162 | "cell_type": "markdown", 163 | "metadata": {}, 164 | "source": [ 165 | "**Tuples**\n", 166 | "\n", 167 | "Tuples similar to lists, but they aren't designed to change values like in a list. They use ```()``` to surround their values instead of ```[]``` for lists. You can't add a value like this or you will get an error.\n", 168 | "```python\n", 169 | "chickens[0] = 'Ancona'\n", 170 | "```" 171 | ] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": null, 176 | "metadata": {}, 177 | "outputs": [], 178 | "source": [ 179 | "chickens = (\"Leghorn\", 'Barnevelder', 'Plymouth Rock')\n", 180 | "print(chickens)" 181 | ] 182 | }, 183 | { 184 | "cell_type": "markdown", 185 | "metadata": {}, 186 | "source": [ 187 | "### Activity\n", 188 | "\n", 189 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 190 | "\n", 191 | "Use user input to add temperature values to a list with the ```.append()``` function. One temperature value is collected each second for 20 seconds. If you see an error `You already have an open connection` then restart your Python kernel." 192 | ] 193 | }, 194 | { 195 | "cell_type": "code", 196 | "execution_count": null, 197 | "metadata": {}, 198 | "outputs": [], 199 | "source": [ 200 | "import tclab\n", 201 | "import time\n", 202 | "\n", 203 | "lab = tclab.TCLab()\n", 204 | "\n", 205 | "# initialize lists\n", 206 | "tm = []\n", 207 | "T1 = []\n", 208 | "\n", 209 | "# turn on heater 1\n", 210 | "lab.Q1(60)\n", 211 | "\n", 212 | "for i in range(20):\n", 213 | " tm.append(i)\n", 214 | " print(i,lab.T1)\n", 215 | " # store the new temperature in the list T1 with .append()\n", 216 | "\n", 217 | " time.sleep(1)\n", 218 | "\n", 219 | "print(T1)\n", 220 | "lab.close()" 221 | ] 222 | }, 223 | { 224 | "cell_type": "markdown", 225 | "metadata": {}, 226 | "source": [ 227 | "Make a ```for``` loop that uses at least **5 values**, stored in a ```list```, of your choice to turn on the __LED light__ and __both heaters__. It should end with **0** to make sure the light **and** heaters are off. \n", 228 | "\n", 229 | "Make sure there is a **3 second** break in between each light and heater changes, and print out the temperatures from the heaters every time the program loops." 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": null, 235 | "metadata": {}, 236 | "outputs": [], 237 | "source": [ 238 | "my_List = [\"5 different numbers\", 0] # Put 5 numbers in this list, last one should be zero" 239 | ] 240 | } 241 | ], 242 | "metadata": { 243 | "kernelspec": { 244 | "display_name": "Python 3", 245 | "language": "python", 246 | "name": "python3" 247 | }, 248 | "language_info": { 249 | "codemirror_mode": { 250 | "name": "ipython", 251 | "version": 3 252 | }, 253 | "file_extension": ".py", 254 | "mimetype": "text/x-python", 255 | "name": "python", 256 | "nbconvert_exporter": "python", 257 | "pygments_lexer": "ipython3", 258 | "version": "3.7.4" 259 | } 260 | }, 261 | "nbformat": 4, 262 | "nbformat_minor": 2 263 | } 264 | -------------------------------------------------------------------------------- /11. Dictionaries.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 11. Dictionaries\n", 8 | "\n", 9 | "![list](https://apmonitor.com/che263/uploads/Begin_Python/list.png)\n", 10 | "\n", 11 | "Dictionaries are a list with key and value pairs.\n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=klEt6bU0bYg&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Dictionaries](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython11.png)](https://www.youtube.com/watch?v=klEt6bU0bYg&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Dictionaries\")\n", 16 | "\n", 17 | "The format for this method of storing values is curly brackets ```{}``` as seen below. After you assign a dictionary a name, you can enter values by putting a value followed by a colon to indicate the corresponding value. Multiple corresponding values in a dictionary are separated by commas. You can also print the corresponding value of the key, using brackets ```[]```." 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": null, 23 | "metadata": { 24 | "scrolled": true 25 | }, 26 | "outputs": [], 27 | "source": [ 28 | "dictionary = {} # An empty dictionary\n", 29 | "print(dictionary)\n", 30 | "\n", 31 | "new_Dictionary = {1: 'First value', 2: 'Second value', 3: 'Third value'} # Dictionary with 3 keys / values\n", 32 | "print(new_Dictionary)" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "Many things can be done to dictionaries, including changing values, adding new keys, and more." 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": null, 45 | "metadata": { 46 | "scrolled": false 47 | }, 48 | "outputs": [], 49 | "source": [ 50 | "new_Dictionary = {1: 'First value', 2: 'Second value', 3: 'Third value'}\n", 51 | "print(new_Dictionary)\n", 52 | "\n", 53 | "print(new_Dictionary[2]) # Prints corresponding value for 2\n", 54 | "\n", 55 | "new_Dictionary[2] = \"This is different\" # Changes corresponding value for 2\n", 56 | "\n", 57 | "print(new_Dictionary[2])\n", 58 | "\n", 59 | "print(new_Dictionary)" 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": {}, 65 | "source": [ 66 | "Creating another key is like changing a value, but instead of using the same key name, like ```new_Dictionary[2]``` you make a new one, such as ```new_Dictionary[4]```." 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": null, 72 | "metadata": {}, 73 | "outputs": [], 74 | "source": [ 75 | "definitions = {'egg': 'an oval or round object laid by a female bird, reptile, fish, or invertebrate',\\\n", 76 | " 'chick': 'a young bird, especially one newly hatched'}\n", 77 | "print(definitions)\n", 78 | "\n", 79 | "definitions['hatchling'] = 'a young animal that has recently emerged from its egg'\n", 80 | "print(definitions)" 81 | ] 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "metadata": {}, 86 | "source": [ 87 | "### Activity\n", 88 | "\n", 89 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 90 | "\n", 91 | "Create a dictionary of animals that lay eggs (at least three) with a discription of them as the value. \n", 92 | "\n", 93 | "![animal eggs](https://apmonitor.com/che263/uploads/Begin_Python/animal_eggs.png)\n", 94 | "\n", 95 | "Make a while loop with an input to ask for the description of an animal. The `while` loop should stop if equal to ```\"none\"```. Make sure the loop prints the discription of the animal entered." 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "metadata": {}, 102 | "outputs": [], 103 | "source": [ 104 | "animals = {}" 105 | ] 106 | } 107 | ], 108 | "metadata": { 109 | "kernelspec": { 110 | "display_name": "Python 3", 111 | "language": "python", 112 | "name": "python3" 113 | }, 114 | "language_info": { 115 | "codemirror_mode": { 116 | "name": "ipython", 117 | "version": 3 118 | }, 119 | "file_extension": ".py", 120 | "mimetype": "text/x-python", 121 | "name": "python", 122 | "nbconvert_exporter": "python", 123 | "pygments_lexer": "ipython3", 124 | "version": "3.7.5" 125 | } 126 | }, 127 | "nbformat": 4, 128 | "nbformat_minor": 2 129 | } 130 | -------------------------------------------------------------------------------- /12. Plotting.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## 12. Plotting\n", 8 | "\n", 9 | "![list](https://apmonitor.com/che263/uploads/Begin_Python/list.png)\n", 10 | "\n", 11 | "A plot is a visual representation of the data and is especially valuable to analyze data graphically. You can plot with the ```matplotlib``` package.\n", 12 | "\n", 13 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=yyLqmP1AEuU&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 14 | "\n", 15 | "[![Plots](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython12.png)](https://www.youtube.com/watch?v=yyLqmP1AEuU&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Plots\")\n", 16 | "\n", 17 | "In the incubator example, we may want to see how the temperature changes with time. The ```x```-axis may be __time__ and ```y```-axis may be the __data__. In an incubator, graphs could be used for a number of things. Some could be heater percentage, egg temperature, and much more.\n", 18 | "\n", 19 | "In the code below, graphs can have lines that are formatted as dashed lines:\n", 20 | "```python\n", 21 | "plt.plot(x,y,'r--')```\n", 22 | "\n", 23 | "Changing values for ```x``` and ```y``` will change the points that are plotted for the lines. The ```r``` states that a certain line is red, and the ```--``` tells that the same line is also dashed. You can get more line modifiers in the file *Basic Python Equations*, or scroll down to the help command." 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": null, 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import matplotlib.pyplot as plt # shorten to plt\n", 33 | "%matplotlib inline \n", 34 | "\n", 35 | "x = [1, 2, 3, 4] # Times\n", 36 | "\n", 37 | "y = [3, 4, 2, 6] # List with data\n", 38 | "z = [5, 1, 8, 3] # List with data\n", 39 | "\n", 40 | "plt.plot(x,y) # Plots a graph with the list\n", 41 | "plt.plot(x,z,'r--') # 'r--' changes line to red, and to a dashed line\n", 42 | "plt.show() # Outputs graph" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "### Help Command" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "![idea](https://apmonitor.com/che263/uploads/Begin_Python/idea.png)\n", 57 | "\n", 58 | "You can see all available functions by running the code ```help(plt.plot)``` (run after you import matplotlib) or find functions in the file *Python Basic Knowledge*. You can also use the ```help()``` for any other function in python." 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": null, 64 | "metadata": {}, 65 | "outputs": [], 66 | "source": [ 67 | "help(plt.plot)" 68 | ] 69 | }, 70 | { 71 | "cell_type": "markdown", 72 | "metadata": {}, 73 | "source": [ 74 | "### Activity\n", 75 | "\n", 76 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 77 | "\n", 78 | "Make a plot using 3 lines with 5 data points each.\n", 79 | "\n", 80 | "```python\n", 81 | "time = [1, 2, 3, 4, 5]\n", 82 | "x = [5,4,0,2,3]\n", 83 | "y = [3,-1,4,6,8]\n", 84 | "z = [1,2,4,8,9]\n", 85 | "```\n", 86 | "\n", 87 | "Use this data to plot (time, x), (time,y), and (time,z). Use the plotting examples or the plotting help above if you need help." 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": null, 93 | "metadata": {}, 94 | "outputs": [], 95 | "source": [ 96 | "import matplotlib.pyplot as plt\n", 97 | "\n", 98 | "time = [1, 2, 3, 4, 5]\n", 99 | "x = [5,4,0,2,3]\n", 100 | "y = [3,-1,4,6,8]\n", 101 | "z = [1,2,4,8,9]" 102 | ] 103 | }, 104 | { 105 | "cell_type": "markdown", 106 | "metadata": {}, 107 | "source": [ 108 | "**Customizing Plots**\n", 109 | "\n", 110 | "Plots are customized with labels (x-label, y-label, title, legend) with more lines of code such as:\n", 111 | "\n", 112 | "```python\n", 113 | "plt.xlabel() # add x-label\n", 114 | "plt.ylabel() # add y-label\n", 115 | "plt.title() # add title\n", 116 | "plt.legend() # add legend\n", 117 | "```\n", 118 | "\n", 119 | "There are other ways to modify the plot such as adjusting the range of `y` values (`plt.ylim()`) or range of `x` values (`plt.xlim()`). Each function modifies the plot and they can be used in any order. \n", 120 | "\n", 121 | "You can also create sub-plots by first telling what grid size you'd like to use. In this case, we have 2 rows and 1 column with:\n", 122 | "\n", 123 | "```python\n", 124 | "plt.subplot(2,1,1)\n", 125 | "```\n", 126 | "\n", 127 | "The third number (1) indicates that we are now plotting in the first sub-plot on top. When we give another command:\n", 128 | "\n", 129 | "```python\n", 130 | "plt.subplot(2,1,2)\n", 131 | "```\n", 132 | "\n", 133 | "to begin making modifications to the bottom subplot. There are many examples that can be used as a template for creating [custom plots](https://matplotlib.org/gallery.html)." 134 | ] 135 | }, 136 | { 137 | "cell_type": "markdown", 138 | "metadata": {}, 139 | "source": [ 140 | "**Exporting Plots**\n", 141 | "\n", 142 | "Plots can be exported as a static figure or animated to create a movie.\n", 143 | "\n", 144 | "![MPC MIMO](https://apmonitor.com/do/uploads/Main/mpc_mimo_tclab.gif)\n", 145 | "\n", 146 | "A plot is exported by using the function:\n", 147 | "\n", 148 | "```python\n", 149 | "plt.savefig('FileName.png')\n", 150 | "```\n", 151 | "\n", 152 | "(Common file extensions for export are `.png`, `.jpg`, and `.eps`. Changing the name of the file extension changes the type and size of the file export. Portable Network Graphics(`.png`) files work well for import into a presentation or into a report document.)" 153 | ] 154 | }, 155 | { 156 | "cell_type": "markdown", 157 | "metadata": {}, 158 | "source": [ 159 | "#### Where did it save the file?\n", 160 | "\n", 161 | "Sometimes it can be hard to find the directory where Python saved the figure. You can display your current run folder by running the following Python cell." 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": null, 167 | "metadata": {}, 168 | "outputs": [], 169 | "source": [ 170 | "import os\n", 171 | "print(\"Figure saved in current directory: \" + os.getcwd())" 172 | ] 173 | }, 174 | { 175 | "cell_type": "markdown", 176 | "metadata": {}, 177 | "source": [ 178 | "### Activity\n", 179 | "\n", 180 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 181 | "\n", 182 | "Try the code below to add a title, x-label, and y-label. \n", 183 | "\n", 184 | "Adjust the `y` range to be between `-1` and `1.2`. Adjust the `x` range to be between `0` and `6`.\n", 185 | "\n", 186 | "The legend (`plt.legend`) gets values to run from lines `plt.plot(label='Your label')`.\n", 187 | "\n", 188 | "**Bonus:** Split the two plots into two subplots. " 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": null, 194 | "metadata": {}, 195 | "outputs": [], 196 | "source": [ 197 | "import matplotlib.pyplot as plt\n", 198 | "import numpy as np\n", 199 | "\n", 200 | "x = np.linspace(0,6,100) # First value is starting point, next is end point, and last is how many points in between\n", 201 | "y = np.sin(x)\n", 202 | "z = np.cos(x)\n", 203 | "\n", 204 | "plt.title('Put title here') # Add a title\n", 205 | "\n", 206 | "plt.plot(x,y, 'r--', linewidth=3, label='y=sin(x)') # linewidth modifies the width of a line\n", 207 | "plt.plot(x,z, 'k:', linewidth=2, label='What is a good label?') # label gives the line a label\n", 208 | "\n", 209 | "plt.legend() # Values given to legend comes from label='Your label' in lines above\n", 210 | "\n", 211 | "plt.xlim([0, 3]) # Set the x range: 0 to 6\n", 212 | "plt.ylim([-1.5, 1.5]) # Set the y range: -1 to 1.2\n", 213 | "\n", 214 | "plt.ylabel('Change y label')\n", 215 | "plt.xlabel('Change x label')\n", 216 | "\n", 217 | "plt.show()" 218 | ] 219 | }, 220 | { 221 | "cell_type": "markdown", 222 | "metadata": {}, 223 | "source": [ 224 | "Make a plot that comes from the lab's temperatures, 30 seconds of data. The code below sets heater one to 70 percent and heater two to 100 percent. It collects data for 30 seconds in the lists `tm`=Time, `T1`=Temperature 1, and `T2`=Temperature 2." 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": null, 230 | "metadata": {}, 231 | "outputs": [], 232 | "source": [ 233 | "import tclab\n", 234 | "import time\n", 235 | "\n", 236 | "lab = tclab.TCLab()\n", 237 | "\n", 238 | "# initialize lists\n", 239 | "tm = []\n", 240 | "T1 = []\n", 241 | "T2 = []\n", 242 | "\n", 243 | "# turn on heater 1\n", 244 | "lab.Q1(70); lab.Q2(100)\n", 245 | "\n", 246 | "# collect data for 30 seconds\n", 247 | "for i in range(30):\n", 248 | " tm.append(i)\n", 249 | " T1.append(lab.T1)\n", 250 | " T2.append(lab.T2)\n", 251 | " print(tm[i],T1[i],T2[i])\n", 252 | " time.sleep(1)\n", 253 | "lab.close()" 254 | ] 255 | }, 256 | { 257 | "cell_type": "markdown", 258 | "metadata": {}, 259 | "source": [ 260 | "Make the plotting lines modified to your liking. Because you're using two heaters, you should have two lines to represent the two temperatures." 261 | ] 262 | }, 263 | { 264 | "cell_type": "code", 265 | "execution_count": null, 266 | "metadata": {}, 267 | "outputs": [], 268 | "source": [ 269 | "import matplotlib.pyplot as plt\n", 270 | "%matplotlib inline\n", 271 | "\n", 272 | "plt.plot(tm,T1,'r--',label='T1')\n", 273 | "# add plot for temperature 2\n", 274 | "\n", 275 | "plt.legend()\n", 276 | "plt.xlabel('Add x-label')\n", 277 | "plt.ylabel('Add y-label')\n", 278 | "plt.savefig('temperatures.png')\n", 279 | "plt.show()" 280 | ] 281 | } 282 | ], 283 | "metadata": { 284 | "kernelspec": { 285 | "display_name": "Python 3", 286 | "language": "python", 287 | "name": "python3" 288 | }, 289 | "language_info": { 290 | "codemirror_mode": { 291 | "name": "ipython", 292 | "version": 3 293 | }, 294 | "file_extension": ".py", 295 | "mimetype": "text/x-python", 296 | "name": "python", 297 | "nbconvert_exporter": "python", 298 | "pygments_lexer": "ipython3", 299 | "version": "3.7.4" 300 | } 301 | }, 302 | "nbformat": 4, 303 | "nbformat_minor": 2 304 | } 305 | -------------------------------------------------------------------------------- /Basic Python Knowledge.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": { 5 | "search.png": { 6 | "image/png": "iVBORw0KGgoAAAANSUhEUgAACT4AAADZCAYAAAADzb37AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAJOgAACToAYJjBRwAABKgSURBVHhe7d1RbuO4EkDRXpp3lqX10vqhHloYT4Z2JKtIFalzgPqZSRy16M+L4q8/AAAAAAAAAAAAkxE+AQAAAAAAAAAA0xE+AQAA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AAAAAAAAAYCThE2nETwAAAAAAAAAAjCJ8IpX4CQAAAAAAAACAEYRPpBM/AQAAAAAAAADQm/CJLlaInx6Px99/DQAAAAAAAAAA1Qif6Eb8BAAAAAAAAABAL8InulohfnLlHQAAAAAAAABAPcInups9frL1CQAAAAAAAACgHuETQ8weP9n6BAAAAAAAAABQi/CJYWaOn2x9AgAAAAAAAACoRfjEUDPHTwAAAAAAAAAA1KHmYLhZ4yfX3QEAAAAAAAAA1CF84hIzxk/xzAAAAAAAAAAA1CB84jKzxU+Px+PvkwMAAAAAAAAAcDXhE5eaKX4SPgEAAAAAAAAA1CF84nKzxE/CJwAAAAAAAACAOoRPlDBD/CR8AgAAAAAAAACoQ/hEGdXjJ+ETAAAAAAAAAEAdwidKqRw/xbMBAAAAAAAAAFCD8IlyqsZPwicAAAAAAAAAgDqET5RUMX4CAAAAAAAAAKAONQdlVYqfHo/H36cCAAAAAAAAAKAC4ROlVYmfXHMHAAAAAAAAAFCL8InyKsRPAAAAAAAAAADUouhgClfGT7Y9AQAAAAAAAADUI3xiGlfET6InAAAAAAAAAICahE9MZXT8BAAAAAAAAABATcoOpjMqfvr9+/ffvwgAAAAAAAAAQDXCJ6YUUVIrVsoa0RMAAAAAAAAAQG3CJ6b2eDya4dKnE58HAAAAAAAAAEB9wieml3X1nS1PAAAAAAAAAADzED6xjE8CqNjwFL8HAAAAAAAAAMBchE8sJzY3RcwUUdP3q/C2/xY/Y8MTAAAAAAAAAMC8hE8AAAAAAAAAAMB0hE8AAAAAAAAAAMB0hE8AAAAAAAAAAMB0hE8AAAAAAAAAAMB0hE8AAAAAAAAAAMB0hE8AAAAAAAAAAMB0hE8AAAAAAAAAAMBk/vz5H2NVNmg0XG07AAAAAElFTkSuQmCC" 7 | } 8 | }, 9 | "cell_type": "markdown", 10 | "metadata": {}, 11 | "source": [ 12 | "## Internet Resource\n", 13 | "\n", 14 | "![search.png](attachment:search.png)\n", 15 | "\n", 16 | "The internet is an important resource when it comes to general programming information. Learn to search information from tutorial sites and quickly find the information that you need. Specific websites that can be helpful are StackOverflow, Geeks for Geeks, and many more. Below are some helps for math, comparison, logical, plotting, and turtle methods as examples of the types of resources that you'll find. The hardest part about using the Internet as a resource is how to quickly sort through the information to find the specific answer that you need. Sometimes the hardest part is formulating the correct question.\n", 17 | "\n", 18 | "## Shortcuts\n", 19 | "Press h to see or edit the list of every shortcut in Jupyter Notebook" 20 | ] 21 | }, 22 | { 23 | "cell_type": "markdown", 24 | "metadata": {}, 25 | "source": [ 26 | "## Math\n", 27 | "\n", 28 | "\\+\tAddition: adds two operands\tx + y\n", 29 | "\n", 30 | "\\-\tSubtraction: subtracts two operands\tx - y\n", 31 | "\n", 32 | "\\*\tMultiplication: multiplies two operands\tx * y\n", 33 | "\n", 34 | "/\tDivision (float): divides the first operand by the second\tx / y\n", 35 | "\n", 36 | "//\tDivision (floor): divides the first operand by the second\tx // y\n", 37 | "\n", 38 | "%\tModulus: returns the remainder when first operand is divided by the second\tx % y\n", 39 | "\n", 40 | "## Compare\n", 41 | "\n", 42 | "\\>\tGreater than: True if left operand is greater than the right\tx > y\n", 43 | "\n", 44 | "<\tLess than: True if left operand is less than the right\tx < y\n", 45 | "\n", 46 | "==\tEqual to: True if both operands are equal\tx == y\n", 47 | "\n", 48 | "!=\tNot equal to - True if operands are not equal\tx != y\n", 49 | "\n", 50 | "\\>=\tGreater than or equal to: True if left operand is greater than or equal to the right\tx >= y\n", 51 | "\n", 52 | "<=\tLess than or equal to: True if left operand is less than or equal to the right\tx <= y\n", 53 | "\n", 54 | "## Logical \n", 55 | "\n", 56 | "and\tLogical AND: True if both the operands are true\tx and y\n", 57 | "\n", 58 | "or\tLogical OR: True if either of the operands is true\tx or y\n", 59 | "\n", 60 | "not\tLogical NOT: True if operand is false\tnot x" 61 | ] 62 | }, 63 | { 64 | "attachments": { 65 | "plot.png": { 66 | "image/png": "iVBORw0KGgoAAAANSUhEUgAACSYAAADBCAYAAADYMfwRAAAAAXNSR0IArs4c6QAAAAR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ib plotting\n", 73 | "\n", 74 | "![plot.png](attachment:plot.png)\n", 75 | "\n", 76 | "**Colors**\n", 77 | " \n", 78 | " ============= ===============================\n", 79 | " character color\n", 80 | " ============= ===============================\n", 81 | " ``'b'`` blue\n", 82 | " ``'g'`` green\n", 83 | " ``'r'`` red\n", 84 | " ``'c'`` cyan\n", 85 | " ``'m'`` magenta\n", 86 | " ``'y'`` yellow\n", 87 | " ``'k'`` black\n", 88 | " ``'w'`` white\n", 89 | " ============= ===============================\n", 90 | " \n", 91 | "**Markers**\n", 92 | " \n", 93 | " ============= ===============================\n", 94 | " character description\n", 95 | " ============= ===============================\n", 96 | " ``'.'`` point marker\n", 97 | " ``','`` pixel marker\n", 98 | " ``'o'`` circle marker\n", 99 | " ``'v'`` triangle_down marker\n", 100 | " ``'^'`` triangle_up marker\n", 101 | " ``'<'`` triangle_left marker\n", 102 | " ``'>'`` triangle_right marker\n", 103 | " ``'1'`` tri_down marker\n", 104 | " ``'2'`` tri_up marker\n", 105 | " ``'3'`` tri_left marker\n", 106 | " ``'4'`` tri_right marker\n", 107 | " ``'s'`` square marker\n", 108 | " ``'p'`` pentagon marker\n", 109 | " ``'*'`` star marker\n", 110 | " ``'h'`` hexagon1 marker\n", 111 | " ``'H'`` hexagon2 marker\n", 112 | " ``'+'`` plus marker\n", 113 | " ``'x'`` x marker\n", 114 | " ``'D'`` diamond marker\n", 115 | " ``'d'`` thin_diamond marker\n", 116 | " ``'|'`` vline marker\n", 117 | " ``'_'`` hline marker\n", 118 | " ============= ===============================\n", 119 | " \n", 120 | "**Line Styles**\n", 121 | " \n", 122 | " ============= ===============================\n", 123 | " character description\n", 124 | " ============= ===============================\n", 125 | " ``'-'`` solid line style\n", 126 | " ``'--'`` dashed line style\n", 127 | " ``'-.'`` dash-dot line style\n", 128 | " ``':'`` dotted line style\n", 129 | " ============= ===============================" 130 | ] 131 | } 132 | ], 133 | "metadata": { 134 | "kernelspec": { 135 | "display_name": "Python 3", 136 | "language": "python", 137 | "name": "python3" 138 | }, 139 | "language_info": { 140 | "codemirror_mode": { 141 | "name": "ipython", 142 | "version": 3 143 | }, 144 | "file_extension": ".py", 145 | "mimetype": "text/x-python", 146 | "name": "python", 147 | "nbconvert_exporter": "python", 148 | "pygments_lexer": "ipython3", 149 | "version": "3.7.5" 150 | } 151 | }, 152 | "nbformat": 4, 153 | "nbformat_minor": 2 154 | } 155 | -------------------------------------------------------------------------------- /BeginPython.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/BeginPython.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Begin Python 🐍 with the TCLab 2 | 3 | Welcome to this introductory course on Python! This course is intended to help you start programming in Python from little or no prior experience. There are video tutorials for each exercise if you have questions along the way. One of the unique things about this course is that you work on basic elements to help you with a temperature control project. You will see your Python code have a real effect by adjusting heaters to maintain a target temperature, just like a thermostat in a home or office. 4 | 5 | [![Begin Python](https://apmonitor.com/che263/uploads/Begin_Python/BeginPython00.png)](https://www.youtube.com/watch?v=EO_YpBs8cs0 "Begin Python") 6 | 7 | One of the best ways to start or review a programming language is to work on a simple project. These exercises are designed to teach basic Python programming skills to help you design a temperature controller. Temperature control is found in many applications such as home or office HVAC, manufacturing processes, transportation, and life sciences. Even our bodies regulate temperature to a specific set point. This project is to regulate the temperature of the TCLab. Each TCLab has thermochromic (changes color with temperature) paint that turns from black to purple when the temperature reaches the target temperature of 37°C (99°F). 8 | 9 | **[Final Project](https://github.com/APMonitor/begin_python/blob/master/XX.%20Final%20Project.ipynb) Objective**: Program the TCLab to maintain the temperature at 37°C. Display the heater level with an LED indicator as the program is adjusting the temperature. Create a plot of the temperature and heater values over a 10 minute evaluation period. 10 | 11 | To make the problem more concrete, suppose that you are designing a chicken egg incubator. Temperature, humidity, and egg rotation are all important to help the chicks develop. For this exercise, you will only focus on temperature control by adjusting the heater. 12 | 13 | **Topics** 14 | 15 | There are 12 lessons to help you with the objective of designing the temperature control for the incubator. The first thing that you will need is to [install Anaconda](https://github.com/APMonitor/begin_python/blob/master/00.%20Introduction.ipynb) to open and run the IPython notebook files in Jupyter. Any Python distribution or Integrated Development Environment (IDE) can be used (IDLE (python.org), Spyder, PyCharm, and others) but Jupyter notebook is required to open and run the IPython notebook (`.ipynb`) files. All of the IPython notebook (`.ipynb`) files can be [downloaded at this link](https://github.com/APMonitor/begin_python/archive/master.zip). Don't forget to unzip the folder (extract the archive) and copy it to a convenient location before starting. 16 | 17 | 1. [Overview](https://github.com/APMonitor/begin_python/blob/master/01.%20Overview.ipynb) 18 | 2. [Debugging](https://github.com/APMonitor/begin_python/blob/master/02.%20Debugging.ipynb) 19 | 3. [Variables](https://github.com/APMonitor/begin_python/blob/master/03.%20Variables.ipynb) 20 | 4. [Printing](https://github.com/APMonitor/begin_python/blob/master/04.%20Printing.ipynb) 21 | 5. [Classes and Objects](https://github.com/APMonitor/begin_python/blob/master/05.%20Classes%20and%20Objects.ipynb) 22 | 6. [Functions](https://github.com/APMonitor/begin_python/blob/master/06.%20Functions.ipynb) 23 | 7. [Loops](https://github.com/APMonitor/begin_python/blob/master/07.%20Loops.ipynb) 24 | 8. [Input](https://github.com/APMonitor/begin_python/blob/master/08.%20Input.ipynb) 25 | 9. [If Statements](https://github.com/APMonitor/begin_python/blob/master/09.%20If%20Statements.ipynb) 26 | 10. [Lists and Tuples](https://github.com/APMonitor/begin_python/blob/master/10.%20Lists%20and%20Tuples.ipynb) 27 | 11. [Dictionaries](https://github.com/APMonitor/begin_python/blob/master/11.%20Dictionaries.ipynb) 28 | 12. [Plotting](https://github.com/APMonitor/begin_python/blob/master/12.%20Plotting.ipynb) 29 | 30 | **Get TCLab** 31 | 32 | You will need a [TCLab kit](https://apmonitor.com/heat.htm) to complete the exercises and they are available for [purchase on Amazon](https://www.amazon.com/TCLab-Temperature-Control-Lab/dp/B07GMFWMRY). 33 | 34 | ![Temperature Control Lab](https://apmonitor.com/pdc/uploads/Main/tclab_connect.png "TCLab") 35 | 36 | **Install Python** 37 | 38 | [Download and install Python](https://www.anaconda.com/products/individual) or watch a video on how to install Python. 39 | 40 | **[Install Python on Windows](https://youtu.be/_BHsM452vK0)** 41 | 42 | [![Install Python on Windows](https://img.youtube.com/vi/_BHsM452vK0/0.jpg)](https://www.youtube.com/watch?v=_BHsM452vK0 "Install Python on Windows") 43 | 44 | **[Install Python on MacOS](https://youtu.be/2VECcPofhP8)** 45 | 46 | [![Install Python on MacOS](https://img.youtube.com/vi/2VECcPofhP8/0.jpg)](https://www.youtube.com/watch?v=2VECcPofhP8 "Install Python on MacOS") 47 | 48 | **[Install Python on Linux](https://youtu.be/eUq-6ZuwC_A)** 49 | 50 | [![Install Python on Linux](https://img.youtube.com/vi/eUq-6ZuwC_A/0.jpg)](https://www.youtube.com/watch?v=eUq-6ZuwC_A "Install Python on Linux") 51 | 52 | There are additional instructions on how to [install Python and manage modules](https://apmonitor.com/pdc/index.php/Main/InstallPython). 53 | 54 | **Support** 55 | 56 | We would love to hear any feedback or problems you would like to send us! We are always trying to improve this course and would like to hear about your experience. We can be contacted at _eric@apmonitor.com_ or _john@apmonitor.com_. 57 | 58 | **Additional Resources** 59 | 60 | - [Temperature Control Lab (TCLab) Kit](https://apmonitor.com/pdc/index.php/Main/ArduinoTemperatureControl) 61 | - [Engineering Programming Course](https://apmonitor.com/pdc) with [Source Code](https://github.com/APMonitor/learn_python) 62 | - [Jupyter as interactive environment for Python, Julia, R](https://jupyter.org/) 63 | -------------------------------------------------------------------------------- /XX. Final Project.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Final Project\n", 8 | "\n", 9 | "The final project is to put together all of the basic parts of the course to help you complete a project to design the temperature control for an egg incubator. This is an opportunity for you to review the course material as you use many of the elements that you learned in Lessons 1-12.\n", 10 | "\n", 11 | "[Python Playlist on YouTube](https://www.youtube.com/watch?v=5Ry5fKdxNAw&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46)", 12 | "\n", 13 | "[![Incubator Project](https://apmonitor.com/che263/uploads/Begin_Python/BeginPythonXX.png)](https://www.youtube.com/watch?v=5Ry5fKdxNAw&list=PLLBUgWXdTBDi3J05aMVG1knUpqRhkbc46 \"Incubator Project\")\n", 14 | "\n", 15 | "A good place to start is to create high-level instructions (pseudo-code) on what you want the program to do. Next, start filling in those parts of the code and test each part as you go. The final test is for 10 minutes but use a shorter time (maybe 10 seconds) as you test your code. Good luck!\n", 16 | "\n", 17 | "![expert](https://apmonitor.com/che263/uploads/Begin_Python/expert.png)\n", 18 | "\n", 19 | "**Objective**: Program the TCLab to maintain the temperature (`T1`) at 37°C by adjusting the heater (`Q1`). Display the heater level (`Q1`) with an LED indicator as the program is adjusting the temperature. Create a plot of the temperature and heater values over a 10 minute evaluation period.\n", 20 | "\n", 21 | "![hatch](https://apmonitor.com/che263/uploads/Begin_Python/hatch.png)" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [] 30 | } 31 | ], 32 | "metadata": { 33 | "kernelspec": { 34 | "display_name": "Python 3", 35 | "language": "python", 36 | "name": "python3" 37 | }, 38 | "language_info": { 39 | "codemirror_mode": { 40 | "name": "ipython", 41 | "version": 3 42 | }, 43 | "file_extension": ".py", 44 | "mimetype": "text/x-python", 45 | "name": "python", 46 | "nbconvert_exporter": "python", 47 | "pygments_lexer": "ipython3", 48 | "version": "3.7.4" 49 | } 50 | }, 51 | "nbformat": 4, 52 | "nbformat_minor": 2 53 | } 54 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /module_images/BeginPython00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython00.png -------------------------------------------------------------------------------- /module_images/BeginPython01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython01.png -------------------------------------------------------------------------------- /module_images/BeginPython02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython02.png -------------------------------------------------------------------------------- /module_images/BeginPython03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython03.png -------------------------------------------------------------------------------- /module_images/BeginPython04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython04.png -------------------------------------------------------------------------------- /module_images/BeginPython05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython05.png -------------------------------------------------------------------------------- /module_images/BeginPython06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython06.png -------------------------------------------------------------------------------- /module_images/BeginPython07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython07.png -------------------------------------------------------------------------------- /module_images/BeginPython08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython08.png -------------------------------------------------------------------------------- /module_images/BeginPython09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython09.png -------------------------------------------------------------------------------- /module_images/BeginPython10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython10.png -------------------------------------------------------------------------------- /module_images/BeginPython11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython11.png -------------------------------------------------------------------------------- /module_images/BeginPython12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPython12.png -------------------------------------------------------------------------------- /module_images/BeginPythonXX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/APMonitor/begin_python/51efab138488f4c2e3a348d207901659d9e70f0f/module_images/BeginPythonXX.png --------------------------------------------------------------------------------