aboutsummaryrefslogtreecommitdiff
path: root/lessons/.ipynb_checkpoints
diff options
context:
space:
mode:
Diffstat (limited to 'lessons/.ipynb_checkpoints')
-rw-r--r--lessons/.ipynb_checkpoints/hw1-checkpoint.ipynb528
1 files changed, 528 insertions, 0 deletions
diff --git a/lessons/.ipynb_checkpoints/hw1-checkpoint.ipynb b/lessons/.ipynb_checkpoints/hw1-checkpoint.ipynb
new file mode 100644
index 0000000..15ca091
--- /dev/null
+++ b/lessons/.ipynb_checkpoints/hw1-checkpoint.ipynb
@@ -0,0 +1,528 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Objects and Data Structures Assessment Test"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "## Test your knowledge. \n",
+ "\n",
+ "** Answer the following questions **"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "Write a brief description of all the following Object Types and Data Structures we've learned about: "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Numbers:\n",
+ "\n",
+ "Strings:\n",
+ "\n",
+ "Lists:\n",
+ "\n",
+ "Tuples:\n",
+ "\n",
+ "Dictionaries:\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Numbers\n",
+ "\n",
+ "Write an equation that uses multiplication, division, an exponent, addition, and subtraction that is equal to 100.25.\n",
+ "\n",
+ "Hint: This is just to test your memory of the basic arithmetic commands, work backwards from 100.25"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Answer these 3 questions without typing code. Then type code to check your answer.\n",
+ "\n",
+ " What is the value of the expression 4 * (6 + 5)\n",
+ " \n",
+ " What is the value of the expression 4 * 6 + 5 \n",
+ " \n",
+ " What is the value of the expression 4 + 6 * 5 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "What is the *type* of the result of the expression 3 + 1.5 + 4?<br><br>"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "What would you use to find a number’s square root, as well as its square? "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Square root:\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Square:\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Strings"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Given the string 'hello' give an index command that returns 'e'. Enter your code in the cell below:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "s = 'hello'\n",
+ "# Print out 'e' using indexing\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Reverse the string 'hello' using slicing:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "s ='hello'\n",
+ "# Reverse the string using slicing\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Given the string hello, give two methods of producing the letter 'o' using indexing."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "s ='hello'\n",
+ "# Print out the 'o'\n",
+ "\n",
+ "# Method 1:\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Method 2:\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Lists"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Build this list [0,0,0] two separate ways."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Method 1:\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Method 2:\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Reassign 'hello' in this nested list to say 'goodbye' instead:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "list3 = [1,2,[3,4,'hello']]\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Sort the list below:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "list4 = [5,3,4,6,1]\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Dictionaries"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Using keys and indexing, grab the 'hello' from the following dictionaries:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "d = {'simple_key':'hello'}\n",
+ "# Grab 'hello'\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "d = {'k1':{'k2':'hello'}}\n",
+ "# Grab 'hello'\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Getting a little tricker\n",
+ "d = {'k1':[{'nest_key':['this is deep',['hello']]}]}\n",
+ "\n",
+ "#Grab hello\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# This will be hard and annoying!\n",
+ "d = {'k1':[1,2,{'k2':['this is tricky',{'tough':[1,2,['hello']]}]}]}"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Can you sort a dictionary? Why or why not?<br><br>"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Tuples"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "What is the major difference between tuples and lists?<br><br>"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "How do you create a tuple?<br><br>"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Sets "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "What is unique about a set?<br><br>"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Use a set to find the unique values of the list below:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "list5 = [1,2,2,33,4,4,11,22,3,3,2]\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Booleans"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "For the following quiz questions, we will get a preview of comparison operators. In the table below, a=3 and b=4.\n",
+ "\n",
+ "<table class=\"table table-bordered\">\n",
+ "<tr>\n",
+ "<th style=\"width:10%\">Operator</th><th style=\"width:45%\">Description</th><th>Example</th>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>==</td>\n",
+ "<td>If the values of two operands are equal, then the condition becomes true.</td>\n",
+ "<td> (a == b) is not true.</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>!=</td>\n",
+ "<td>If values of two operands are not equal, then condition becomes true.</td>\n",
+ "<td> (a != b) is true.</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>&gt;</td>\n",
+ "<td>If the value of left operand is greater than the value of right operand, then condition becomes true.</td>\n",
+ "<td> (a &gt; b) is not true.</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>&lt;</td>\n",
+ "<td>If the value of left operand is less than the value of right operand, then condition becomes true.</td>\n",
+ "<td> (a &lt; b) is true.</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>&gt;=</td>\n",
+ "<td>If the value of left operand is greater than or equal to the value of right operand, then condition becomes true.</td>\n",
+ "<td> (a &gt;= b) is not true. </td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>&lt;=</td>\n",
+ "<td>If the value of left operand is less than or equal to the value of right operand, then condition becomes true.</td>\n",
+ "<td> (a &lt;= b) is true. </td>\n",
+ "</tr>\n",
+ "</table>"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "What will be the resulting Boolean of the following pieces of code (answer fist then check by typing it in!)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Answer before running cell\n",
+ "2 > 3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Answer before running cell\n",
+ "3 <= 2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Answer before running cell\n",
+ "3 == 2.0"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Answer before running cell\n",
+ "3.0 == 3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Answer before running cell\n",
+ "4**0.5 != 2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Final Question: What is the boolean output of the cell block below?"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# two nested lists\n",
+ "l_one = [1,2,[3,4]]\n",
+ "l_two = [1,2,{'k1':4}]\n",
+ "\n",
+ "# True or False?\n",
+ "l_one[2][0] >= l_two[2]['k1']"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Great Job on your first assessment! "
+ ]
+ }
+ ],
+ "metadata": {
+ "anaconda-cloud": {},
+ "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": 1
+}