{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "bound-citizen",
   "metadata": {},
   "source": [
    "<h1>Python Programming: Variables</h1>\n",
    "\n",
    "## Overview\n",
    "This lesson introduces students to the concept of creating and assigning variables - numeric variables (including basic math functions / numerical operators) and string variables (including concatenation). There is a small section near the end on different ways to print these variables.\n",
    "\n",
    "---\n",
    "## Lesson Objectives\n",
    "*After this lesson, you will be able to...*\n",
    "\n",
    "* Create and re-assign numerical and string variables.\n",
    "* Use numerical operators.\n",
    "* Print complex variable structures.\n",
    "\n",
    "---\n",
    "## What's a Variable?\n",
    "\n",
    "Turn to the person next to you, and together come up with as many definitions for the word \"variable\" as you can.\n",
    "\n",
    "- Consider contexts such as mathematics, the sciences, weather, etc.\n",
    "- No cheating! Phones off and laptops closed.\n",
    "---\n",
    "## Variable\n",
    "\n",
    "\n",
    "Variables:\n",
    "\n",
    "- Are boxes that can hold all kinds of information for you.\n",
    "- Make it easier to store and re-use values.\n",
    "- Are the most basic piece of code.\n",
    "\n",
    "To use a variable, we simply announce that we want to use it (we **declare** it).\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "assisted-cradle",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n"
     ]
    }
   ],
   "source": [
    "# I've eaten 3 cupcakes\n",
    "cupcakes_ive_eaten = 3\n",
    "print(cupcakes_ive_eaten)\n",
    "# Prints 3\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "spare-mentor",
   "metadata": {},
   "source": [
    "---\n",
    "## Naming Conventions: Mistakes and Syntax\n",
    "\n",
    "Some common naming mistakes:\n",
    "\n",
    "- Not using meaningful names. `delicious = 3` doesn't mean anything - `cupcakes_ive_eaten = 3` does!\n",
    "- Case sensitivity (`CUPCAKES_IVE_EATEN` and `cupcakes_ive_eaten` are not the same!)\n",
    "- No spaces or punctuation (\"cupcakes i've eaten\" isn't allowed)\n",
    "  - This is invalid **syntax**\n",
    "  - Use snake_case: `lowercase_letters_with_underscores` (it's in the official [Python style guide](https://www.python.org/dev/peps/pep-0008/#descriptive-naming-styles))\n",
    "---\n",
    "## Discussion: Changing Values\n",
    "\n",
    "What if, later, you eat more cupcakes? Now, this is wrong."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fossil-biodiversity",
   "metadata": {},
   "outputs": [],
   "source": [
    "cupcakes_ive_eaten = 3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "western-hamilton",
   "metadata": {},
   "source": [
    "---\n",
    "## Discussion: Reassigning Variables\n",
    "\n",
    "\n",
    "\n",
    "In the example below, what do you think the output of the code is?\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "expanded-fitting",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "cupcakes_ive_eaten = 3\n",
    "print(cupcakes_ive_eaten)\n",
    "cupcakes_ive_eaten = 4\n",
    "print(cupcakes_ive_eaten)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "previous-blast",
   "metadata": {},
   "source": [
    "---\n",
    "## Quick Review\n",
    "\n",
    "- A variable is a box that holds a value.\n",
    "\n",
    "- It can be declared, called, and changed within your program.\n",
    "\n",
    "- When declaring variables, syntax and naming conventions matter!\n",
    "\n",
    "- Variables can be reassigned as often as you like, but only the most recent declaration counts.\n",
    "\n",
    "**UP NEXT:** Math!\n",
    "\n",
    "---\n",
    "## Mathematical Operators\n",
    "\n",
    "Math works on numerical variables, too!\n",
    "\n",
    "- The `+`, `-`, `*` (multiply), and `/` (divide) operators work just like they do with regular math.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "essential-mozambique",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9\n",
      "3\n",
      "18\n",
      "2.0\n"
     ]
    }
   ],
   "source": [
    "cupcakes_ive_eaten = 6 + 3\n",
    "print(cupcakes_ive_eaten)\n",
    "# Prints 9\n",
    "\n",
    "cupcakes_ive_eaten = 6 - 3\n",
    "print(cupcakes_ive_eaten)\n",
    "# Prints 3\n",
    "\n",
    "cupcakes_ive_eaten = 6 * 3\n",
    "print(cupcakes_ive_eaten)\n",
    "# Prints 18\n",
    "\n",
    "cupcakes_ive_eaten = 6 / 3\n",
    "print(cupcakes_ive_eaten)\n",
    "# Prints 2\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ancient-morrison",
   "metadata": {},
   "source": [
    "---\n",
    "## Even More Mathematical Operators\n",
    "\n",
    "Beyond the `+`, `-`, `*` (multiply), and `/` (divide) operators, we have modulus and exponents.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "assigned-fellowship",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100\n",
      "1000\n",
      "1\n",
      "0\n"
     ]
    }
   ],
   "source": [
    "making_exponents = 10 ** 2\n",
    "print(making_exponents)\n",
    "# Prints 100\n",
    "\n",
    "more_exponents = 10 ** 3\n",
    "print(more_exponents)\n",
    "# Prints 1,000\n",
    "\n",
    "making_modulus = 10 % 3\n",
    "print(making_modulus)\n",
    "# Prints 1\n",
    "\n",
    "more_modulus = 6 % 2\n",
    "print(more_modulus)\n",
    "# Prints 0\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "amber-madison",
   "metadata": {},
   "source": [
    "---\n",
    "## Math On The Same Variable\n",
    "\n",
    "\n",
    "You can reassign a variable *using that very same variable* - or other variables!\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "unknown-poker",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "5\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "cupcakes_ive_eaten = 3\n",
    "cupcakes_ive_eaten = cupcakes_ive_eaten + 1\n",
    "print(cupcakes_ive_eaten)\n",
    "# Prints 4.\n",
    "\n",
    "cupcakes_left_in_box = 6\n",
    "cupcakes_left_in_box = cupcakes_left_in_box - 1 \n",
    "print(cupcakes_left_in_box)\n",
    "# Prints 5.\n",
    "\n",
    "cupcakes_left_in_box = cupcakes_left_in_box - cupcakes_ive_eaten \n",
    "print(cupcakes_left_in_box)\n",
    "# Prints 1.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "confused-buying",
   "metadata": {},
   "source": [
    "---\n",
    "## Partner Exercise: Mathematical Operators\n",
    "\n",
    "In pair programming, one person serves as the driver -- they are sharing their screen and typing -- and one person serves as the navigator -- they provide guidance as the code is written.\n",
    "- When you pair up, decide who will be the driver and who will be the navigator. Then, follow the directions in the comments."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "magnetic-bullet",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# Make a variable to hold the number of guitars you own (3).\n",
    "guitars_i_own = 3\n",
    "\n",
    "# Make a variable to hold the number of guitars Nikhil owns (1).\n",
    "guitars_nikhil_owns = 1\n",
    "\n",
    "# You give 2 of your guitars to Nikhil, so subtract 2 from you and add 2 to Nikhil.\n",
    "guitars_i_own = guitars_i_own - 2\n",
    "guitars_nikhil_owns = guitars_nikhil_owns + 2\n",
    "\n",
    "print(guitars_i_own)\n",
    "print(guitars_nikhil_owns)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "republican-separation",
   "metadata": {},
   "source": [
    "---\n",
    "## Reassignment Shorthand\n",
    "\n",
    "This is okay:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "robust-brunei",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "16\n"
     ]
    }
   ],
   "source": [
    "my_num = 9\n",
    "my_num = my_num + 7\n",
    "# my_num is now 16\n",
    "print(my_num)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "streaming-simulation",
   "metadata": {},
   "source": [
    "\n",
    "But this is better:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "separate-alliance",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "16\n"
     ]
    }
   ],
   "source": [
    "my_num = 9\n",
    "my_num += 7 # += is short for theSameVariable = theSameVariable + 7\n",
    "# my_num is now 16\n",
    "print(my_num)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dress-healing",
   "metadata": {},
   "source": [
    "This works with `+=`, `-=`, `*=`, `/=` - any math operations.\n",
    "\n",
    "---\n",
    "## Partner Exercise: Numerical Reassignment\n",
    "\n",
    "Get with the same partner, but switch driver and navigator roles.\n",
    "\n",
    "- Remember, in pair programming, one person serves as the driver -- their hands are on the keyboard -- and one person serves as the navigator -- they provide guidance as the code is written.\n",
    "- Follow the directions in the comments."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "willing-senegal",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9 9 1\n"
     ]
    }
   ],
   "source": [
    "# - Declare two variables `num1` and `num2` and assign them to any numbers you'd like.\n",
    "num1 = 5\n",
    "num2 = 9\n",
    "# - Set `num1` to the result of subtracting `num1` from the `num2`.\n",
    "num1 = num2 - num1\n",
    "# - Create a new variable `num3` that will help us tell if `num2` is even or odd.\n",
    "num3 = num2 % 2\n",
    "# - Using shorthand, add 5 to `num1`.\n",
    "num1 += 5\n",
    "# - Print out `num1`, `num2`, and `num3`\n",
    "print(num1, num2, num3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "continental-publication",
   "metadata": {},
   "source": [
    "---\n",
    "## Important Aside: Even or Odd?\n",
    "\n",
    "Is 6 even or odd?\n",
    "\n",
    "Is 7 even or odd?\n",
    "\n",
    "How do you think a computer knows?\n",
    "\n",
    "Modulus operator shows the remainder of a division problem.\n",
    "\n",
    "Modding by 2 only gives a `0` or a `1`.\n",
    "\n",
    "- **4 % 2**:\n",
    "  - `4 % 2 = 0`. Even!\n",
    "- **5 % 2**:\n",
    "  - `5 % 2 = 1`. Odd!\n",
    "---\n",
    "## Quick Review\n",
    "\n",
    "- A variable is a value that can be defined, declared, called and changed within your program.\n",
    "    - `my_number = 5`\n",
    "- Naming:\n",
    "    - Variable names are case sensitive.\n",
    "    - Use `snake_case`!\n",
    "- Variables can be reassigned as often as you like, but only the most recent declaration counts.\n",
    "- Python can do math using operators, such as `+`, `-`, `*`, and `/`\n",
    "    - You can shorthand the math assignments: `my_num += 7`\n",
    "---\n",
    "## Taking a Breather\n",
    "\n",
    "That was a lot of math!\n",
    "\n",
    "When it comes down to it, computers operate with a simple, straightforward logic.\n",
    "\n",
    "Let's switch gears. Up next: Strings!\n",
    "\n",
    "---\n",
    "## Introducing Strings\n",
    "\n",
    "A *character* is:\n",
    "\n",
    "- Anything on your keyboard , such as a letter or a number.\n",
    "- \"Apple\" is five characters: a, p, p, l, e.\n",
    "- Spaces count! (they're on the keyboard!)\n",
    "\n",
    "A *string* is:\n",
    "\n",
    "- A complete list of characters.\n",
    "- \"Apple\"\n",
    "- \"Chocolate Cupcake\"\n",
    "- This entire sentence: \"Hello, you are 1 of a kind!\"\n",
    "\n",
    "---\n",
    "\n",
    "## How Do I Create Strings in Python?\n",
    "\n",
    "\n",
    "You tell Python that your variable will hold a string using quotation marks."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "fossil-encoding",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cupcakes\n"
     ]
    }
   ],
   "source": [
    "box_contents = \"cupcakes\" # This is a string\n",
    "print(box_contents) # It's a normal variable - we can print it.\n",
    "best_snack = \"Frosted Cupcakes\" # This is a string.\n",
    "cupcakes_ive_eaten = 5 # No quotes - this is a number.\n",
    "cupcakes_ive_eaten_as_string = \"5\" # Because this is in quotes, this is a string.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "warming-spyware",
   "metadata": {},
   "source": [
    "---\n",
    "## We Do: Declaring Strings\n",
    "\n",
    "A \"We Do\" means let's practice together. Follow along!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "aboriginal-brain",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Marty Delorean 88\n"
     ]
    },
    {
     "ename": "TypeError",
     "evalue": "can only concatenate str (not \"int\") to str",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-18-b61d252537bf>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      8\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcar\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mspeed\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      9\u001b[0m \u001b[1;31m# 5. We'll add `4` to `speed`- what happens?\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 10\u001b[1;33m \u001b[0mspeed\u001b[0m \u001b[1;33m+=\u001b[0m \u001b[1;36m4\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str"
     ]
    }
   ],
   "source": [
    "# 1. We'll declare a variable called `name` and assign it the value `Marty`\n",
    "name = 'Marty'\n",
    "# 2. We'll declare a variable called `car` and assign it the value `Delorean`\n",
    "car = 'Delorean'\n",
    "# 3. We'll declare a variable called `speed` and assign it the *string* value `\"88\"`\n",
    "speed = '88'\n",
    "# 4. We'll print out these variables\n",
    "print(name, car, speed)\n",
    "# 5. We'll add `4` to `speed`- what happens?\n",
    "speed += 4 "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "classical-peninsula",
   "metadata": {},
   "source": [
    "---\n",
    "## String Concatenation\n",
    "\n",
    "`+` on:\n",
    "\n",
    "- Numerical variables adds (`5 + 5 = 10`).\n",
    "- String variables *concatenate* (`\"Doc\" + \"Brown\" = \"DocBrown\"`).\n",
    "  - *Pssst: Pronunciation tip: con-CAT-en-ATE*\n",
    "- Numerical strings concatenate to new strings! (`\"5\" + `\"4\"` = `\"54\"`)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "equipped-david",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DocBrown\n"
     ]
    }
   ],
   "source": [
    "first_name = \"Doc\"\n",
    "last_name = \"Brown\"\n",
    "full_name = first_name + last_name\n",
    "print (full_name)\n",
    "# Prints \"DocBrown\"."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "derived-gothic",
   "metadata": {},
   "source": [
    "---\n",
    "## We Do: Spaces in Concatenation\n",
    "\n",
    "It's another \"We Do.\" Let's do this together -  follow along!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "bacterial-square",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Martyis driving hisDelorean88\n"
     ]
    }
   ],
   "source": [
    "sentence = name + \"is driving his\" + car + speed\n",
    "print(sentence)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "jewish-travel",
   "metadata": {},
   "source": [
    "We expect the sentence to be `Marty is driving his Delorean 88mph`. Is that what we got?\n",
    "\n",
    "- Python put the strings together, but do you notice anything wrong? There is no space between the words! This is because we didn't add the spaces in. It's just one of many reasons why we have to carefully watch our spacing and grammar!\"\n",
    "- Since a space is a character - it's on the keyboard - we can make it a string. Therefore, we can add it into our concatenation. By default, concatenation doesn't have spaces - you'll always have to add them yourself.\n",
    "- You can also `print` directly; you don't necessarily need an extra variable. To print strings next to each other, you separate them with a comma. Then, Python will add the space for you. This isn't concatenating variables, but it's useful to know! Change code to: `sentence = name + \" is driving his \" + car + \" \" + speed`\n",
    "- When `print`ing, commas also create spaces. Change code to: `print(name, \"is driving his\", car, speed)`\n",
    "---\n",
    "## f-strings\n",
    "\n",
    "- f-strings are a way that you can include variables directly in your strings, without having to use concatenation.\n",
    "- They are so-called because you create them by adding the letter 'f' just before the string: `f\"This is an f-string\"`.\n",
    "- You can then include variables or other Python expressions inside your f-string by wrapping them in `{}`: `print(f'{name} is driving their {car} {speed}mph.')`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "irish-transparency",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Marty is driving their Delorean 88mph.\n"
     ]
    }
   ],
   "source": [
    "print(f'{name} is driving their {car} {speed}mph.')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "knowing-assembly",
   "metadata": {},
   "source": [
    "</aside>\n",
    "\n",
    "---\n",
    "\n",
    "## Strings and Printing: Review\n",
    "\n",
    "Strings are made with quotes:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "industrial-harbor",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = \"Marty\"\n",
    "car = \"Delorean\"\n",
    "speed = \"88\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "greater-volunteer",
   "metadata": {},
   "source": [
    "\n",
    "String Concatenation - we need to add the spaces!\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "successful-wednesday",
   "metadata": {},
   "outputs": [],
   "source": [
    "sentence = name + \" is driving his \" + car + \" \" + speed\n",
    "string_numbers = \"88\" + \"51\"\n",
    "# string_numbers = 8851\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "headed-cross",
   "metadata": {},
   "source": [
    "\n",
    "To easily create spaces while printing:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "assisted-positive",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Marty is driving his Delorean 88\n",
      "Marty is driving their Delorean 88mph.\n"
     ]
    }
   ],
   "source": [
    "print(name, \"is driving his\", car, speed)\n",
    "\n",
    "# Or using f-strings\n",
    "\n",
    "print(f'{name} is driving their {car} {speed}mph.')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "unauthorized-compensation",
   "metadata": {},
   "source": [
    "\n",
    "---\n",
    "\n",
    "## Discussion: Some Common Mistakes: 1\n",
    "\n",
    "\n",
    "Do you think this will run? If yes, what does it print?\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "musical-reviewer",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'new_num' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-29-a6a38b1867b8>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mnew_num\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnew_num\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'new_num' is not defined"
     ]
    }
   ],
   "source": [
    "new_num\n",
    "print(new_num)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "waiting-louisiana",
   "metadata": {},
   "source": [
    "\n",
    "---\n",
    "\n",
    "## Discussion: Some Common Mistakes: 2\n",
    "\n",
    "How about this? Does it run? If so, what does it print?\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "gothic-hardware",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "my_num = 5\n",
    "print()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ignored-handbook",
   "metadata": {},
   "source": [
    "\n",
    "<aside class=\"notes\">\n",
    "\n",
    "Answer: It will run, but it won't print anything.\n",
    "\n",
    "</aside>\n",
    "\n",
    "---\n",
    "\n",
    "## Discussion: Some Common Mistakes: 3\n",
    "\n",
    "How about this? Does it run? If so, what does it print?\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "automotive-crown",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for +: 'int' and 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-31-8bb94c6033d8>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mmy_num\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m5\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0mmy_string\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\"Hello\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmy_num\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mmy_string\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'"
     ]
    }
   ],
   "source": [
    "my_num = 5\n",
    "my_string = \"Hello\"\n",
    "print(my_num + my_string)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "flexible-tunnel",
   "metadata": {},
   "source": [
    "\n",
    "<aside class=\"notes\">\n",
    "\n",
    "Answer: This won't run, because Python will try to add a string and a number and throw an error.\n",
    "\n",
    "</aside>\n",
    "\n",
    "---\n",
    "\n",
    "## Discussion: Some Common Mistakes: 4\n",
    "\n",
    "One last question. What does this do?\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "federal-marriage",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1020\n"
     ]
    }
   ],
   "source": [
    "my_num1 = \"10\"\n",
    "my_num2 = \"20\"\n",
    "print(my_num1 + my_num2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "thrown-sussex",
   "metadata": {},
   "source": [
    "\n",
    "<aside class=\"notes\">\n",
    "\n",
    "Answer: There's nothing wrong with this one, except that it makes a string and not a number. It prints the string 1020.\n",
    "\n",
    "</aside>\n",
    "\n",
    "---\n",
    "\n",
    "## Q&A and Summary\n",
    "\n",
    "We learned a lot today!\n",
    "\n",
    "- We created, used, and re-assigned number and string variables.\n",
    "- We used the numerical operators `+ - / * // %`\n",
    "- We did some complex stuff with the `print` function!\n",
    "\n",
    "Congrats! You've finished your first programming lesson!\n",
    "\n",
    "<aside class=\"notes\">\n",
    "\n",
    "**Teaching Tips**:\n",
    "\n",
    "- Summarize the lesson and provide a preview of what’s coming next.\n",
    "- Open your own blank [repl.it](https://repl.it/@GAcoding/blank-repl) in a new tab if needed to recap and be sure everyone is clear.\n",
    "\n",
    "</aside>\n",
    "\n",
    "\n",
    "---\n",
    "\n",
    "## Additional Resources\n",
    "\n",
    "* [A Repl.it Summarizing Print Statements](https://repl.it/@brandiw/Python-01-Variables-4?lite=true)\n",
    "* [Python For Beginners](http://www.pythonforbeginners.com/basics/python-variables)\n",
    "* [Python Programming Tutorial: Variables](https://www.youtube.com/watch?v=vKqVnr0BEJQ)\n",
    "* [Variables in Python](https://www.guru99.com/variables-in-python.html)\n",
    "* [Operators Cheatsheet](http://python-reference.readthedocs.io/en/latest/docs/operators/)\n",
    "* [Python Style Guide: Naming](https://www.python.org/dev/peps/pep-0008/#descriptive-naming-styles)\n",
    "- [Python-Strings](https://www.tutorialspoint.com/python/python_strings.htm)\n",
    "- [String Concatenation and Formatting](http://www.pythonforbeginners.com/concatenation/string-concatenation-and-formatting-in-python)\n",
    "- [String Concatenation and Formatting - Video](https://www.youtube.com/watch?v=jA5LW3bR0Us)\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.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
