Commit a7fe1175 authored by George Mount's avatar George Mount
Browse files

load files

parent 742f575e
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# DRILLS\n",
"\n",
"1. Assign the sum of -10 and 2 to `a`.\n",
"2. Assign the absolute value of `a` to `b`.\n",
"3. Assign `b` minus 1 as `d`.\n",
"4. Print the result of `d`. What is the value? What type is this variable?\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"7\n",
"<class 'int'>\n"
]
}
],
"source": [
"a = -10 + 2\n",
"b = abs(a)\n",
"d = b - 1\n",
"\n",
"print(d)\n",
"print(type(d))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# DRILL\n",
"\n",
"1. Create a list containing the values `North`, `East`, `South` and `West`. \n",
"2. What is the result of the below?\n",
"\n",
"```\n",
"len(['Monday','Tuesday','Wednesday','Thursday','Friday',['Saturday','Sunday']])\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['North', 'East', 'South', 'West']\n",
"6\n"
]
}
],
"source": [
"directions = ['North','East','South','West']\n",
"print(directions)\n",
"\n",
"print(len(['Monday','Tuesday','Wednesday','Thursday','Friday',['Saturday','Sunday']]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# DRILL\n",
"\n",
"1. What do you expect to be the result of the following? Run the code and see how you did.\n",
"\n",
"```\n",
"my_week = (['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])\n",
"my_week.sort()\n",
"print(my_week)\n",
"```\n",
"\n",
"2. Pass the `clear()` method to `my_week` from above. Re-print `my_week`. What happens?"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Friday', 'Monday', 'Saturday', 'Sunday', 'Thursday', 'Tuesday', 'Wednesday']\n"
]
}
],
"source": [
"my_week = (['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])\n",
"my_week.sort()\n",
"print(my_week)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[]\n"
]
}
],
"source": [
"my_week.clear()\n",
"\n",
"print(my_week)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Drill\n",
"\n",
"Practice some more slicing below:"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[7, 12, 5]\n",
"[5, 10]\n",
"[12, 5, 10, 9]\n"
]
}
],
"source": [
"my_list = [7,12,5,10,9]\n",
"\n",
"# Get the first through third elements\n",
"print(my_list[0:3])\n",
"\n",
"# Get the third-last to second-last elements\n",
"print(my_list[-3:-1])\n",
"\n",
"# Get the second through last elements\n",
"print(my_list[1:5])\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Drill\n",
"\n",
"The `factorial()` function from `math` will take the factorial of a number `X`.\n",
"\n",
"Find the factorial of 10 using this function."
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3628800"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import math\n",
"\n",
"math.factorial(10)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Drill \n",
"\n",
"Install the `seaborn` package."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#!pip install seaborn"
]
}
],
"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.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# DRILLS\n",
"\n",
"1. Assign the sum of -10 and 2 to `a`.\n",
"2. Assign the absolute value of `a` to `b`.\n",
"3. Assign `b` minus 1 as `d`.\n",
"4. Print the result of `d`. What is the value? What type is this variable?\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"7\n",
"<class 'int'>\n"
]
}
],
"source": [
"a = -10 + 2\n",
"b = abs(a)\n",
"d = b - 1\n",
"\n",
"print(d)\n",
"print(type(d))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# DRILL\n",
"\n",
"1. Create a list containing the values `North`, `East`, `South` and `West`. \n",
"2. What is the result of the below?\n",
"\n",
"```\n",
"len(['Monday','Tuesday','Wednesday','Thursday','Friday',['Saturday','Sunday']])\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['North', 'East', 'South', 'West']\n",
"6\n"
]
}
],
"source": [
"directions = ['North','East','South','West']\n",
"print(directions)\n",
"\n",
"print(len(['Monday','Tuesday','Wednesday','Thursday','Friday',['Saturday','Sunday']]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# DRILL\n",
"\n",
"1. What do you expect to be the result of the following? Run the code and see how you did.\n",
"\n",
"```\n",
"my_week = (['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])\n",
"my_week.sort()\n",
"print(my_week)\n",
"```\n",
"\n",
"2. Pass the `clear()` method to `my_week` from above. Re-print `my_week`. What happens?"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Friday', 'Monday', 'Saturday', 'Sunday', 'Thursday', 'Tuesday', 'Wednesday']\n"
]
}
],
"source": [
"my_week = (['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])\n",
"my_week.sort()\n",
"print(my_week)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[]\n"
]
}
],
"source": [
"my_week.clear()\n",
"print(my_week)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Drill\n",
"\n",
"Practice some more slicing below:"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[7, 12, 5]\n",
"[5, 10]\n",
"[12, 5, 10, 9]\n"
]
}
],
"source": [
"my_list = [7,12,5,10,9]\n",
"\n",
"# Get the first through third elements\n",
"print(my_list[0:3])\n",
"\n",
"# Get the third-last to second-last elements\n",
"print(my_list[-3:-1])\n",
"\n",
"# Get the second through last elements\n",
"print(my_list[1:5])\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## DRILL\n",
"\n",
"Practice slicing lists below. \n",
"\n",
"These operations will work the same regardless of whether your list contains floats, strings, or other data types."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['on', 'lists', 'of', 'strings', 'identically']\n",
"['Slicing', 'works', 'on', 'lists']\n",
"['strings', 'identically']\n"
]
}
],
"source": [
"this_list = [\"Slicing\",\"works\",\"on\",\"lists\",\"of\",\"strings\",\"identically\"]\n",
"\n",
"# Get the third to final elements\n",
"print(this_list[2:])\n",
"\n",
"\n",
"# Get everything up to the fourth element\n",
"print(this_list[:4])\n",
"\n",
"\n",
"# Get everything starting with the second-last element\n",
"print(this_list[-2:])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Drill\n",
"\n",
"The `factorial()` function from `math` will take the factorial of a number `X`.\n",
"\n",
"Find the factorial of 10 using this function."
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3628800"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import math\n",
"\n",
"math.factorial(10)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Drill \n",
"\n",
"Install the `seaborn` package."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#!pip install seaborn"
]
}
],
"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.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
name,Year,Population,Density
Alabama,2010,4785492,50750
Alabama,2011,4799918,50750
Alabama,2012,4815960,50750
Alabama,2013,4829479,50750
Alabama,2014,4843214,50750
Alabama,2015,4853875,50750
Alabama,2016,4863300,50750
Alaska,2010,714031,570641
Alaska,2011,722713,570641
Alaska,2012,731089,570641
Alaska,2013,736879,570641
Alaska,2014,736705,570641
Alaska,2015,737709,570641
Alaska,2016,741894,570641
Arizona,2010,6408312,113642
Arizona,2011,6467163,113642
Arizona,2012,6549634,113642
Arizona,2013,6624617,113642
Arizona,2014,6719993,113642
Arizona,2015,6817565,113642
Arizona,2016,6931071,113642
Arkansas,2010,2921995,52075
Arkansas,2011,2939493,52075
Arkansas,2012,2950685,52075
Arkansas,2013,2958663,52075
Arkansas,2014,2966912,52075
Arkansas,2015,2977853,52075
Arkansas,2016,2988248,52075
California,2010,37332685,155973
California,2011,37676861,155973