Skip to content

Instantly share code, notes, and snippets.

@acangiano
Created December 3, 2018 21:02
Show Gist options
  • Save acangiano/5b2a4f6b2196cab73698769f0fed3e4d to your computer and use it in GitHub Desktop.
Save acangiano/5b2a4f6b2196cab73698769f0fed3e4d to your computer and use it in GitHub Desktop.
Created on Cognitive Class Labs
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" <a href=\"http://cocl.us/NotebooksPython101\"><img src = \"https://ibm.box.com/shared/static/yfe6h4az47ktg2mm9h05wby2n7e8kei3.png\" width = 750, align = \"center\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Welcome!\n",
"\n",
"By the end of this notebook, you will have learned the basics of Python, including writing some basic commands, understanding object types, and some simple operations! "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Table of Contents\n",
"\n",
"\n",
"<div class=\"alert alert-block alert-info\" style=\"margin-top: 20px\">\n",
"<li><a href=\"#ref0\">First Program in Python</a></li>\n",
"<li><a href=\"#ref1\">Object Types </a></li>\n",
"<li><a href=\"#ref2\">Expressions and Variables</a></li>\n",
"\n",
"<br>\n",
"<p></p>\n",
"Estimated Time Needed: <strong>25 min</strong>\n",
"</div>\n",
"\n",
"<hr>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" <a id=\"ref0\"></a>\n",
"<h2 align=center>Your First Program in Python </h2> "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A statement or expression is an instruction the computer will run or execute. Perhaps the simplest program you can write is to print a statement in Python."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-success alertsuccess\" style=\"margin-top: 20px\">\n",
"**Tip**: To *execute* the Python code in the grey code cell below, **click on it and press Shift + Enter**.\n",
"</div>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print('Hello World!')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After executing the cell above, you should see that Python return the string, `Hello Python 101`. Congratulations on running your first Python code!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-success alertsuccess\" style=\"margin-top: 20px\">\n",
"**Tip:** **`print()`** is the **function** that you **executed**, and you *passed in* an **argument** of `'Hello World!'`.\n",
"</div>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Python 3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"How do we know that Python 3 is running? Take a look in the top-right hand corner of this notebook. You should see \"Python 3\"!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Writing comments in Python"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In addition to writing code, note that it is customary to comment your code to help describe what it does. Not only does this help **other people** understand your code, it can also serve as a _reminder_ **to you** of what your code does. (This is especially true when you write some code and then come back to it weeks or months later.)\n",
"\n",
"To write comments in your Python code, use the hash symbol (#) before writing your comment. When you run the code Python will ignore everything after the # in that line."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print('Hello Python 101') #this my comment\n",
"#print('Hi')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Great! After executing the cell above, you should notice that **\"this is my comment** did not appeared in the output, because it was a comment (and thus ignored by Python). \n",
"The second line was also not executed because `print('Hi')` was preceded by a hash symbol (#) as well!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Errors in Python"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before continuing, it's important to note when things go wrong in Python, and we cause **errors**."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are many kinds of errors, and you **do not need to memorize the various types of errors**. Instead, what's most important is know **what the error messages mean**.\n",
"\n",
"For example, if you spell **print** as **frint**, you will get an error message."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"frint(\"Hello World!\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The error message tells you (1) where the error occurred, and (2) what kind of error it was. Here, Python attempted to run the function `frint`, but could not determine what `frint` -- since it is _undefined_."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Does Python know the error in the script before you run it?\n",
"No, Python is naive! Python will try to run the code line-by-line, and it will stop if it runs into an error."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(\"This will be printed\")\n",
"frint(\"This will cause an error\")\n",
"print(\"This will NOT be printed\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"More on errors later on in this course!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exercise: Your First Program"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Using the `print()` function, print out the phrase: \"hello world\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Write your code below and press Shift+Enter to execute \n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"\n",
"\n",
"print(\"hello world!\")\n",
"\n",
"-->"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Print out the phrase: \"Hello World\" and comment it with the phrase \"printing Hello World\" _all in one line of code_"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Write your code below\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"\n",
"print(\"Hello World\") #print Hello World\n",
"\n",
"-->\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"ref1\"></a>\n",
"<h2 align=center> Types of objects in Python </h2>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can have many different object types in Python, let's start with **strings**, **integers** and **floats**. Anytime you write words (text) in Python, you're using character **strings** (strings for short). Numbers, on the other hand, depend: numbers can be **integers** (like -1, 0, 100) or **floats**, which are real numbers (like 3.14, -42.0)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" <a,align = \"center\"><img src = \"https://ibm.box.com/shared/static/8zp0t4oh7kuzleudrszhkqukcup1708f.png\" width = 600></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The following chart summarizes three data types for the last examples, the first column indicates the expression the second column indicates the data type\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"11 #integer"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"2.14 #float"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"\"Hello Python 101\" #character string"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We can see the actual data type in python by using the **`type()`** command"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(12)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(2.14)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(\"Hello Python 101\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Using the `type()` function, check the object type of `12.0`?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Write your code below\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Integers"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here are some integers, integers can be negative or positive:\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a align = \"center\"><img src = \"https://ibm.box.com/shared/static/19iqm3q5pvxzuwa22d5ihxcr6eftjl48.png\" width = 600></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can verify some of the above examples using the type command:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(-1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(4)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Floats "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" Floats are real numbers; they include the integers but also \"numbers in-between the integers\". Consider the numbers between 0 and one we can select numbers in-between them, these numbers are floats. Similarly, consider the numbers between 0.5 and 0.6. We can select numbers in-between them, these are floats as well. We can continue the process, zooming in for different numbers, of course, there is a limit, but it is quite small."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We can verify some of the above examples using the type command:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(1.0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(0.5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(0.56)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Converting from one object type to a different object type"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can change the type of the object in Python; this is called typecasting. For example, you can convert an integer into a float, as in 2 to 2.0."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(2) #verify that this is an integer"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Converting to float:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"float(2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(float(2))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Converting to integer:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" Nothing really changes. If you cast a float to an integer, you must be careful. For example, if you cast the float 1.1 to 1 you will lose some information : "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"int(1.1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Converting from strings to integers/floats:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If a string contains an integer value, you can convert it to an integer:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"int('1')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also convert strings containing float values into float objects"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"float('1.2')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"However, if we attempt to convert a string that contains a non-numerical value, we get an error:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"int(\"A\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Converting to strings:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can convert an int to a string:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"str(1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" You can convert a float to a string "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"str(1.2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Boolean "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Boolean is another important type in Python; a Boolean can take on two values. The first value is true, just remember we use an uppercase T:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"True"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" Boolean values can also be false, with an uppercase F:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"False"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Using the type command on a Boolean value we obtain the term bool, this is short for Boolean "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"type(False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we cast a Boolean true to an integer or float we will get a 1, if we cast a Boolean false to an integer or float. If we get a zero if you cast a 1 to a boolean, you get a true similarly, if you cast a 0 to a Boolean you get a false. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"int(True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"bool(1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"bool(0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"float(True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Quiz on types "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### What is the type of the result of: `6 / 2`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"the type if float \n",
"type(6/2)\n",
"-->"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### What is the type of the result of: `6 // 2`? (Note the double slash //)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"int:\n",
"double slashes stand for integer division \n",
"\n",
"\n",
"-->"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"ref2\"></a>\n",
"<h2 align=center> Expression and Variables </h2>\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Expressions "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Expressions are operations that Python performs. For example, basic arithmetic operations like adding multiple numbers."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"43 + 60 + 16 + 41"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We can perform operations such as subtraction using the subtraction sign. In this case the result is a negative number."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"50 - 60"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can use multiplication using an asterisk:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"5 * 5"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also perform division with the forward slash"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"25 / 5"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"25 / 6"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can use the double slash for integer division, where the result is rounded "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"25//5"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"25//6"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**What is 160 min in hours?**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"160.0 / 60.0\n",
"```\n",
"-->"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" Python follows mathematical conventions when performing mathematical expressions. The following operations are in different order. In both cases Python performs multiplication, then addition to obtain the final result. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
" 2 * 60 + 30"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" The expressions in the parentheses are performed first. We then multiply the result by 60, the result is 1920."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"(30 + 2) * 60"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-success alertsuccess\" style=\"margin-top: 20px\">\n",
"<h4> [Tip] Summary </h4>\n",
"<p></p>\n",
"You can do a variety of mathematical operations in Python including: \n",
"<li> addition: **2 + 2** </li>\n",
"<li> subtraction: **5 - 2** </li>\n",
"<li> multiplication: **3 \\* 2** </li>\n",
"<li> division: **4 / 2** </li>\n",
"<li> exponentiation: **4 \\*\\* 2** </li>\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Variables"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also **store** our output in **variables**, so we can use them later on. For example:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x = 43 + 60 + 16 + 41"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To return the value of **`x`**, we can simply run the variable as a command:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"x"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also perform operations on **`x`** and save the result to a **new variable**:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"y = x / 60\n",
"y"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we save something to an **existing variable**, it will **overwrite** the previous value:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"x = x / 60\n",
"x"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It's good practice to use **meaningful variable names**, so you don't have to keep track of what variable is what:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"total_min = (43 + 42 )\n",
"total_min"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"total_hr = total_min / 60 \n",
"total_hr"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can put this all into a single expression, but remember to use **round brackets** to add together the album lengths first, before dividing by 60."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"total_hr = (43 + 42 + 57) / 60 # get total hours in a single expression\n",
"total_hr"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr></hr>\n",
"<div class=\"alert alert-success alertsuccess\" style=\"margin-top: 0px\">\n",
"<h4> [Tip] Variables in Python </h4>\n",
"<p></p>\n",
"As you just learned, you can use **variables** to store values for repeated use. Here are some more **characteristics of variables in Python**:\n",
"<li>variables store the output of a block of code </li>\n",
"<li>variables are typically assigned using **=** (as in **x = 1**) </li>\n",
"<p></p>\n",
"</div>\n",
"<hr></hr>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" <a id=\"#ref1a\"></a>\n",
"<h2 align=center> Quiz on Expression and Variables in Python</h2>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### What is the value of x ? <p> x = 3 + 2 * 2</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"7\n",
"-->\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### What is the value of y ? <p> y = (3 + 2) * 2</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"10\n",
"-->"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### What is the value of z ? <p> z = x + y</p>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"\n",
"17\n",
"-->"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" <div class=\"alert alert-block alert-info\" style=\"margin-top: 20px\">\n",
" <a href=\"http://cocl.us/NotebooksPython101bottom\"><img src = \"https://ibm.box.com/shared/static/irypdxea2q4th88zu1o1tsd06dya10go.png\" width = 750, align = \"center\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n",
"Copyright &copy; 2017 IBM Cognitive Class. This notebook and its source code are released under the terms of the [MIT License](https://cognitiveclass.ai/mit-license/)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### About the Authors: \n",
"\n",
"\n",
" [Joseph Santarcangelo](https://www.linkedin.com/in/joseph-s-50398b136/) is a Data Scientist at IBM, and holds a PhD in Electrical Engineering, his research focused on using machine learning, signal processing, and computer vision to determine how videos impact human cognition. Joseph has been working for IBM since he completed his PhD.\n",
"\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment