diff --git a/P1 Python Absolute Beginner/Module_1.0_Tutorials_START_HERE.ipynb b/P1 Python Absolute Beginner/Module_1.0_Tutorials_START_HERE.ipynb
index b162afaf..c17e460d 100644
--- a/P1 Python Absolute Beginner/Module_1.0_Tutorials_START_HERE.ipynb
+++ b/P1 Python Absolute Beginner/Module_1.0_Tutorials_START_HERE.ipynb
@@ -163,14 +163,31 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "hello professor dominic!\n"
+ ]
+ }
+ ],
+ "source": [
+ "# this is to say hello\n",
+ "print(\"hello professor dominic!\")"
+ ]
},
{
"cell_type": "markdown",
- "metadata": {},
+ "metadata": {
+ "editable": true,
+ "slideshow": {
+ "slide_type": ""
+ },
+ "tags": []
+ },
"source": [
"# \n",
" Concepts\n",
@@ -237,7 +254,9 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ " "
+ ]
},
{
"cell_type": "code",
@@ -248,10 +267,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "after edit, save!\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(\"after edit, save!\")"
+ ]
},
{
"cell_type": "markdown",
@@ -272,15 +301,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ctrl s\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(\"ctrl s\")"
+ ]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# Module 1 Part 2\n",
@@ -336,9 +378,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "strings go in single\n",
+ "or double quotes\n"
+ ]
+ }
+ ],
"source": [
"# examples of printing strings with single and double quotes\n",
"print('strings go in single')\n",
@@ -356,14 +407,23 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "strings go in single\n",
+ "or double quotes\n"
+ ]
+ }
+ ],
"source": [
"# [ ] enter a string in the print() function using single quotes\n",
- "\n",
+ "print('strings go in single')\n",
"# [ ] enter a string in the print() function using double quotes\n",
- "\n"
+ "print(\"or double quotes\")\n"
]
},
{
@@ -391,9 +451,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "123\n",
+ "123\n"
+ ]
+ }
+ ],
"source": [
"print(123) #integer, with numeric value\n",
"print(\"123\") #string, represents text characters"
@@ -403,6 +472,9 @@
"cell_type": "markdown",
"metadata": {
"collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ },
"slideshow": {
"slide_type": "slide"
}
@@ -432,9 +504,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "299\n",
+ "2017\n"
+ ]
+ }
+ ],
"source": [
"# printing an Integer with python\n",
"print(299)\n",
@@ -454,15 +535,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "100\n",
+ "100\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print an Integer\n",
- "\n",
+ "print(100)\n",
"\n",
"# [ ] print a strings made of Integer characters\n",
- "\n",
+ "print(\"100\")\n",
"\n"
]
},
@@ -520,9 +610,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "I am a string\n",
+ "Run this cell using Ctrl+Enter\n"
+ ]
+ }
+ ],
"source": [
"# [ ] Review code and Run\n",
"# initialize the variable\n",
@@ -537,11 +636,19 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {
"scrolled": true
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Run this cell using Ctrl+Enter\n"
+ ]
+ }
+ ],
"source": [
"# [ ] Review code and Run\n",
"# assign a new string to the current_msg\n",
@@ -566,12 +673,23 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Run this cell using Ctrl+Enter\n",
+ "This is my new string\n"
+ ]
+ }
+ ],
"source": [
"# { ] run cell above then run this cell after completing the code as directed\n",
- "\n"
+ "print(current_msg)\n",
+ "current_msg = \"This is my new string\"\n",
+ "print(current_msg)"
]
},
{
@@ -651,9 +769,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "22\n",
+ "Joana\n"
+ ]
+ }
+ ],
"source": [
"test_value = 22\n",
"print(test_value)\n",
@@ -673,18 +800,26 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Matthew\n"
+ ]
+ }
+ ],
"source": [
"# [ ] assign a string value to a variable student_name\n",
- "\n",
+ "student_name = \"Matthew\"\n",
"# [ ] print the value of variable student_name\n",
- "\n"
+ "print(student_name)\n"
]
},
{
@@ -699,18 +834,27 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Josh\n",
+ "Seth\n"
+ ]
+ }
+ ],
"source": [
"# [ ] assign the student_name variable a different string value (a different name)\n",
- "\n",
+ "student_name = \"Josh\"\n",
"# [ ] print the value of variable student_name\n",
- "\n",
+ "print(student_name)\n",
"# [ ] assign a 3rd different string value, to the variable name \n",
- "\n",
+ "student_name = \"Seth\"\n",
"# [ ] print the value of variable name\n",
- "\n"
+ "print(student_name)\n"
]
},
{
@@ -726,18 +870,27 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "String\n",
+ "15\n"
+ ]
+ }
+ ],
"source": [
"# [ ] assigning a value to a variable called bucket\n",
- "\n",
+ "bucket = \"String\"\n",
"# [ ] print the value of bucket \n",
- "\n",
+ "print(bucket)\n",
"# [ ] assign an Integer value (no quotes) to the variable bucket\n",
- "\n",
+ "bucket = 15\n",
"# [ ] print the value of bucket \n",
- "\n",
+ "print(bucket)\n",
"\n"
]
},
@@ -800,9 +953,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Read and run the code\n",
"type(\"Hello World!\")"
@@ -810,27 +974,60 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "int"
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"type(501)"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 11,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "float"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"type(8.33333)"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 12,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"student_name = \"Colette Browning\"\n",
"type(student_name)"
@@ -848,105 +1045,217 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "int"
+ ]
+ },
+ "execution_count": 13,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] show the type after assigning bucket = a whole number value such as 16 \n",
- "\n",
+ "bucket = 16\n",
+ "type(bucket)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 14,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] show the type after assigning bucket = a word in \"double quotes\"\n",
- "\n",
+ "bucket = \"Kitty\"\n",
+ "type(bucket)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 15,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of 'single quoting' (use single quotes) \n",
- "\n",
+ "type('kitty')\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 16,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of \"double quoting\" (use double quotes)\n",
- "\n"
+ "type(\"kitty\")\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 18,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of \"12\" (use quotes)\n",
- "\n"
+ "type(\"12\")\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "int"
+ ]
+ },
+ "execution_count": 19,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of 12 (no quotes)\n",
- "\n"
+ "type(12)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 20,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "int"
+ ]
+ },
+ "execution_count": 20,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of -12 (no quotes)\n",
- "\n"
+ "type(-12)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 23,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "float"
+ ]
+ },
+ "execution_count": 23,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of 12.0 (no quotes)\n",
- "\n"
+ "type(12.0)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 24,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "float"
+ ]
+ },
+ "execution_count": 24,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of 1.55\n",
- "\n"
+ "type(1.55)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 25,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "type"
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] find the type of the type(3) statement (no quotes) - just for fun\n",
- "\n"
+ "type(type(3))\n"
]
},
{
@@ -1017,9 +1326,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 26,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "41"
+ ]
+ },
+ "execution_count": 26,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Review and run code for adding a pair of 2 digit Integers\n",
"23 + 18"
@@ -1027,9 +1347,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 27,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'my name is Alyssa'"
+ ]
+ },
+ "execution_count": 27,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Review and run code for adding 2 strings\n",
"\"my name is \" + \"Alyssa\" "
@@ -1037,9 +1368,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 28,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'my shoe color is brown'"
+ ]
+ },
+ "execution_count": 28,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Review and run code for adding a variable string and a literal string\n",
"shoe_color = \"brown\"\n",
@@ -1057,52 +1399,110 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 29,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "154"
+ ]
+ },
+ "execution_count": 29,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] add 3 integer numbers\n",
- "\n"
+ "20 + 67 + 67\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 30,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "79.0"
+ ]
+ },
+ "execution_count": 30,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] add a float number and an integer number\n",
- "\n"
+ "12.0 + 67\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 31,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'This notebook belongs to Matt.'"
+ ]
+ },
+ "execution_count": 31,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Add the string \"This notebook belongs to \" and a string with your first name\n",
- "\n"
+ "\"This notebook belongs to \" + \"Matt.\"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 32,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "73"
+ ]
+ },
+ "execution_count": 32,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Create variables sm_number and big_number and assign numbers then add the numbers\n",
- "\n"
+ "sm_number = 6\n",
+ "big_number = 67\n",
+ "sm_number + big_number\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 33,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'Matt, remember to save the notebook frequently'"
+ ]
+ },
+ "execution_count": 33,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] assign a string value to the variable first_name and add to the string \", remember to save the notebook frequently\"\n",
- "\n"
+ "first_name = \"Matt\"\n",
+ "first_name + \", remember to save the notebook frequently\"\n"
]
},
{
@@ -1129,9 +1529,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 34,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "50\n",
+ "Happy Birthday Alton\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review & run code for assigning variables & using addition\n",
"add_two = 34 + 16\n",
@@ -1144,9 +1553,19 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 35,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "13\n",
+ "26\n",
+ "\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review & run code for Integer addition in variables and in a print function\n",
"int_sum = 6 + 7\n",
@@ -1157,9 +1576,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 36,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "I do not wear a hat\n",
+ "at dinner\n"
+ ]
+ }
+ ],
"source": [
"# string addition in variables and in print()function\n",
"hat_msg = \"I do not wear \" + \"a hat\" \n",
@@ -1178,37 +1606,62 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "My favorite food is pizza\n"
+ ]
+ }
+ ],
"source": [
"# [ ] perform string addition in the variable named new_msg (add a string to \"my favorite food is \")\n",
"new_msg = \"My favorite food is\"\n",
- "print(new_msg)\n",
+ "print(new_msg + \" pizza\")\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "69\n"
+ ]
+ }
+ ],
"source": [
"# [ ] perform Integer addition in the variable named new_sum (add 2 or more Integers)\n",
"new_sum = 0\n",
- "print(new_sum)\n",
+ "print(new_sum + 2 + 67)\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "My favorite food is pizza\n"
+ ]
+ }
+ ],
"source": [
"# [ ] create and print a new string variable, new_msg_2, that concatenates new_msg + a literal string\n",
- "\n"
+ "new_msg_2 = new_msg + \" pizza\"\n",
+ "print(new_msg_2)\n"
]
},
{
@@ -1269,33 +1722,60 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "48\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run the code - then fix any Errors\n",
- "total_cost = 3 + \"45\"\n",
+ "total_cost = 3 + 45\n",
"print(total_cost)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the street number of Central School is 123\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run the code - then fix any Errors\n",
- "school_num = 123\n",
+ "school_num = \"123\"\n",
"print(\"the street number of Central School is \" + school_num)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "\n",
+ "6.3\n",
+ "this is a float\n"
+ ]
+ }
+ ],
"source": [
"# [ ] Read and run the code - write a hypothesis for what you observe adding float + int\n",
"# [ ] HYPOTHESIS: \n",
@@ -1303,7 +1783,7 @@
"print(type(3.3))\n",
"print(type(3))\n",
"print(3.3 + 3)\n",
- "\n"
+ "print(\"this is a float\")\n"
]
},
{
@@ -1337,14 +1817,23 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hi!\n",
+ "I like the morning\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run the code for properly and improperly formatted print statement\n",
"print(\"Hi!\")\n",
"## Improper format - non matching quotes\n",
- "print('I like the morning\") "
+ "print(\"I like the morning\") "
]
},
{
@@ -1356,12 +1845,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "hi\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run the code \n",
- "prin('hi')"
+ "print('hi')"
]
},
{
@@ -1374,12 +1871,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "where are my socks?\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run the code missing the closing parenthesis \n",
- "print(\"where are my socks?\" "
+ "print(\"where are my socks?\")"
]
},
{
@@ -1391,12 +1896,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "my socks are in the wrong bin\n"
+ ]
+ }
+ ],
"source": [
"# { ] review and run the code \n",
- "print(\"my socks are in the wrong bin)\" "
+ "print(\"my socks are in the wrong bin\")"
]
},
{
@@ -1417,57 +1930,97 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "my socks do not match\n"
+ ]
+ }
+ ],
"source": [
"# [ ] repair the syntax error \n",
- "print('my socks do not match\") \n",
+ "print('my socks do not match') \n",
" \n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "my socks match now\n"
+ ]
+ }
+ ],
"source": [
"# [ ] repair the NameError \n",
- "pront(\"my socks match now\") \n",
+ "print(\"my socks match now\") \n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Save the notebook frequently\n"
+ ]
+ }
+ ],
"source": [
"# [ ] repair the syntax error \n",
- "print\"Save the notebook frequently\")\n",
+ "print(\"Save the notebook frequently\")\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 20,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Alton\n"
+ ]
+ }
+ ],
"source": [
"# [ ] repair the NameError \n",
"student_name = \"Alton\"\n",
- "print(STUDENT_NAME)\n",
+ "print(student_name)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 22,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "3 students are signed up for tutoring\n"
+ ]
+ }
+ ],
"source": [
"# [ ] repair the TypeError\n",
- "total = 3\n",
+ "total = \"3\"\n",
"print(total + \" students are signed up for tutoring\")\n",
"\n"
]
@@ -1522,9 +2075,22 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ " *\n",
+ " * *\n",
+ " *****\n",
+ " * *\n",
+ "* *\n",
+ "\n"
+ ]
+ }
+ ],
"source": [
"# the letter 'A'\n",
"print(\" *\")\n",
@@ -1554,12 +2120,26 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "_ _\n",
+ " / /\n",
+ " / . . /\n",
+ " V\n"
+ ]
+ }
+ ],
"source": [
"# create # [ ] flying bird character art \n",
- "\n"
+ "print(\"_ _\") \n",
+ "print(\" / /\") \n",
+ "print(\" / . . /\") \n",
+ "print(\" V\") \n"
]
},
{
@@ -1572,15 +2152,36 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "*****\n",
+ "*\n",
+ "*****\n",
+ "*\n",
+ "*****\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(\"*****\")\n",
+ "print(\"*\")\n",
+ "print(\"*****\")\n",
+ "print(\"*\")\n",
+ "print(\"*****\")"
+ ]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# Module 1 Part 6\n",
@@ -1606,7 +2207,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -1629,9 +2233,32 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 9,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "enter a small int: \n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ " 4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "small int: \n",
+ "4\n"
+ ]
+ }
+ ],
"source": [
"# review and run code - enter a small integer in the text box\n",
"print(\"enter a small int: \")\n",
@@ -1655,14 +2282,29 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Please give me a student name: Matt\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Student name type is + type(student_name))\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get input for the variable student_name\n",
- "\n",
+ "student_name = input(\"Please give me a student name: \")\n",
"# [ ] determine the type of student_name\n",
- "\n",
+ "print(\"Student name type is + type(student_name))\")\n",
"\n"
]
},
@@ -1683,9 +2325,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "enter a name or number\n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ " Matt\n"
+ ]
+ }
+ ],
"source": [
"# [ ] run cell several times entering a name a int number and a float number after adding code below\n",
"print(\"enter a name or number\")\n",
@@ -1717,9 +2374,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "enter the student name: Matt\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hi Matt\n"
+ ]
+ }
+ ],
"source": [
"student_name = input(\"enter the student name: \") \n",
"print(\"Hi \" + student_name)"
@@ -1738,22 +2410,40 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "enter the city name: Kennesaw\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Kennesaw\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get user input for a city name in the variable named city\n",
- "\n",
+ "city_name = input(\"enter the city name: \")\n",
"# [ ] print the city name\n",
- "\n",
+ "print(city_name)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
- },
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
+ },
"source": [
"\n",
" Task cont... \n",
@@ -1773,16 +2463,39 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Please enter a name: Matt\n",
+ "Please enter an age: 20\n",
+ "Want email promotions? (Yes or No) Yes\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Name: Matt\n",
+ "Age: 20\n",
+ "Do you want email promotions? Yes\n"
+ ]
+ }
+ ],
"source": [
"# [ ]create variables to store input: name, age, get_mail with prompts\n",
"# for name, age and yes/no to being on an email list\n",
- "\n",
+ "name = input(\"Please enter a name: \")\n",
+ "age = input(\"Please enter an age: \")\n",
+ "get_mail = input(\"Want email promotions? (Yes or No)\")\n",
"\n",
"# [ ] print a description + variable value for each variable\n",
- "\n",
+ "print(\"Name: \" + name)\n",
+ "print(\"Age: \" + age)\n",
+ "print(\"Do you want email promotions? \" + get_mail)\n",
"\n"
]
},
@@ -1854,9 +2567,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "41"
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Review and run code for adding a pair of 2 digit Integers\n",
"23 + 18"
@@ -1864,9 +2588,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'my name is Alyssa'"
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Review and run code for adding 2 strings\n",
"\"my name is \" + \"Alyssa\" "
@@ -1874,9 +2609,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 11,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'my shoe color is brown'"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Review and run code for adding a variable string and a literal string\n",
"shoe_color = \"brown\"\n",
@@ -1894,48 +2640,97 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "134"
+ ]
+ },
+ "execution_count": 12,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] add 3 integer numbers\n",
- "\n"
+ "67 + 67\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "134.0"
+ ]
+ },
+ "execution_count": 13,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] add a float number and an integer number\n",
- "\n"
+ "67.0 + 67\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'This notebook belongs to Matt.'"
+ ]
+ },
+ "execution_count": 14,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Add the string \"This notebook belongs to \" and a string with your first name\n",
- "\n"
+ "\"This notebook belongs to \" + \"Matt.\"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "1134"
+ ]
+ },
+ "execution_count": 15,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Create variables sm_number and big_number and assign numbers then add the numbers\n",
- "\n"
+ "sm_number = 67\n",
+ "big_number = 1067\n",
+ "sm_number + big_number\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# Module 1 Part 8\n",
@@ -1961,7 +2756,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -1986,9 +2784,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hello Collette!\n",
+ "Hello to Collette who is from the city\n"
+ ]
+ }
+ ],
"source": [
"# review and run code\n",
"\n",
@@ -2012,12 +2819,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hello Matt the goat!\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print 3 strings on the same line using commas inside the print() function \n",
- "\n"
+ "name = \"Matt\"\n",
+ "print(\"Hello\",name,\"the goat!\")\n"
]
},
{
@@ -2044,9 +2860,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "I will pick you up @ 6 for the party\n"
+ ]
+ }
+ ],
"source": [
"# review and run code\n",
"print(\"I will pick you up @\",6,\"for the party\")"
@@ -2054,9 +2878,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "An Integer of 14 combined with strings causes 0 TypeErrors in comma formatted print!\n"
+ ]
+ }
+ ],
"source": [
"# review and run code\n",
"number_errors = 0\n",
@@ -2074,18 +2906,29 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The number 67 was very popular in 2025\n"
+ ]
+ }
+ ],
"source": [
"# [ ] use a print() function with comma separation to combine 2 numbers and 2 strings\n",
- "\n"
+ "print(\"The number\",67,\"was very popular in\",2025)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
" Task 17 \n",
@@ -2101,15 +2944,32 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Street Name: Kennesaw Ave\n",
+ "Street Number: 10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Address: 10 Kennesaw Ave\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get user input for a street name in the variable, street\n",
- "\n",
+ "street = input(\"Street Name: \")\n",
"# [ ] get user input for a street number in the variable, st_number\n",
- "\n",
+ "st_number = input(\"Street Number: \")\n",
"# [ ] display a message about the street and st_number\n",
+ "print(\"Address: \",st_number,street)\n",
"\n",
"\n"
]
@@ -2125,21 +2985,32 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Matt is the number 1 player in the country.\n"
+ ]
+ }
+ ],
"source": [
"# [ ] define a variable with a string or numeric value\n",
- "\n",
+ "name = \"Matt\"\n",
"# [ ] display a message combining the variable, 1 or more literal strings and a number\n",
- "\n",
+ "print(name,\"is the number\",1,\"player in the country.\")\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
" Task 19 \n",
@@ -2169,34 +3040,66 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 20,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Please enter the name of the owner of this reservation: Matt\n",
+ "Please enter the number of people attending: 10\n",
+ "Please enter the class time you want to reserve: 4:00PM\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Reminder: Training is scheduled at 4:00PM for the Matt group of 10 attendees.\n",
+ "Please arrive 5 minutes early for the first class.\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get input for variables: owner, num_people, training_time - use descriptive prompt text\n",
- "owner = \n",
- "num_people = \n",
- "training_time = \n",
+ "owner = input(\"Please enter the name of the owner of this reservation: \")\n",
+ "num_people = input(\"Please enter the number of people attending: \")\n",
+ "training_time = input(\"Please enter the class time you want to reserve: \")\n",
"# [ ] create a integer variable min_early and \"hard code\" the integer value (e.g. - 5, 10 or 15)\n",
- "min_early = \n",
+ "min_early = 5\n",
"# [ ] print reminder text using all variables & add additional strings - use comma separated print formatting\n",
- "\n",
+ "print(\"Reminder: Training is scheduled at\",training_time,\"for the\",owner,\"group of\",num_people,\"attendees.\")\n",
+ "print(\"Please arrive\",min_early,\"minutes early for the first class.\")\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 23,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Matt, remember to save the notebook frequently.\n"
+ ]
+ }
+ ],
"source": [
- "# [ ] assign a string value to the variable first_name and add to the string \", remember to save the notebook frequently\"\n"
+ "# [ ] assign a string value to the variable first_name and add to the string \", remember to save the notebook frequently\"\n",
+ "first_name = \"Matt\"\n",
+ "print(first_name + \", remember to save the notebook frequently.\")"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# Module 1 Part 9 - Same items as M1 P8 but iterate, change them\n",
@@ -2222,7 +3125,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -2274,12 +3180,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hello Matt the worker!\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print 3 strings on the same line using commas inside the print() function \n",
- "\n"
+ "name = \"Matt\"\n",
+ "print(\"Hello\",name,\"the worker!\")\n"
]
},
{
@@ -2306,9 +3221,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "I will pick you up @ 6 for the party\n"
+ ]
+ }
+ ],
"source": [
"# review and run code\n",
"print(\"I will pick you up @\",6,\"for the party\")"
@@ -2316,9 +3239,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "An Integer of 14 combined with strings causes 0 TypeErrors in comma formatted print!\n"
+ ]
+ }
+ ],
"source": [
"# review and run code\n",
"number_errors = 0\n",
@@ -2336,18 +3267,29 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "An integer of 21 combined with 7 equals 28\n"
+ ]
+ }
+ ],
"source": [
"# [ ] use a print() function with comma separation to combine 2 numbers and 2 strings\n",
- "\n"
+ "print(\"An integer of\",21,\"combined with\",7,\"equals\",28)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
" Task 22 \n",
@@ -2363,16 +3305,32 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Please enter your street name: Collins Place\n",
+ "Please enter your street number: 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Address: 5 Collins Place\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get user input for a street name in the variable, street\n",
- "\n",
+ "street = input(\"Please enter your street name: \")\n",
"# [ ] get user input for a street number in the variable, st_number\n",
- "\n",
+ "st_number = input(\"Please enter your street number: \")\n",
"# [ ] display a message about the street and st_number\n",
- "\n",
+ "print(\"Address:\",st_number,street)\n",
"\n"
]
},
@@ -2387,21 +3345,32 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "I am Matt and I am 20\n"
+ ]
+ }
+ ],
"source": [
"# [ ] define a variable with a string or numeric value\n",
- "\n",
+ "name = \"Matt\"\n",
"# [ ] display a message combining the variable, 1 or more literal strings and a number\n",
- "\n",
+ "print(\"I am\",name,\"and I am\",20)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
" Task 24 \n",
@@ -2431,25 +3400,47 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "enter name for contact person for training group: Matt & Josh\n",
+ "enter the total number attending the course: 2\n",
+ "enter the training time selected: 4:00PM\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Reminder: training is scheduled at 4:00PM for the Matt & Josh group of 2 attendees.\n",
+ "Please arrive 10 minutes early for the first class.\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get input for variables: owner, num_people, training_time - use descriptive prompt text\n",
- "owner = \n",
- "num_people = \n",
- "training_time = \n",
+ "owner = input(\"enter name for contact person for training group: \")\n",
+ "num_people = input(\"enter the total number attending the course: \")\n",
+ "training_time = input(\"enter the training time selected: \")\n",
"# [ ] create a integer variable min_early and \"hard code\" the integer value (e.g. - 5, 10 or 15)\n",
- "min_early = \n",
+ "min_early = 10\n",
"# [ ] print reminder text using all variables & add additional strings - use comma separated print formatting\n",
- "\n",
+ "print(\"Reminder: training is scheduled at\",training_time,\"for the\",owner,\"group of\",num_people,\"attendees.\")\n",
+ "print(\"Please arrive\",min_early,\"minutes early for the first class.\")\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# Module 1 Part 10\n",
@@ -2475,7 +3466,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -2497,9 +3491,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "It's time to save your code\n",
+ "I said to the class \"sometimes you need to shut down and restart a notebook when cells refuse to run\"\n"
+ ]
+ }
+ ],
"source": [
"# review and run the code\n",
"\n",
@@ -2521,28 +3524,48 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Where's the homework?\n"
+ ]
+ }
+ ],
"source": [
"# [ ] using a print statement, display the text: Where's the homework?\n",
- "\n"
+ "print(\"Where's the homework?\")\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Education is what remains after one has forgotten what one has learned in school - Albert Einstein\n"
+ ]
+ }
+ ],
"source": [
"# [ ] output with double quotes: \"Education is what remains after one has forgotten what one has learned in school\" - Albert Einstein\n",
- "\n"
+ "albert = \"Education is what remains after one has forgotten what one has learned in school\"\n",
+ "print(albert,\"- Albert Einstein\")\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
">**note:**: Quotes in quotes handles only simple cases of displaying quotation marks. More complex case are covered later under *escape sequences.*"
@@ -2551,7 +3574,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -2587,45 +3613,97 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 13,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"\"Python\".isalpha()"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 14,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"\"3rd\".isalnum()"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 15,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"\"A Cold Stromy Night\".istitle()"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 16,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"\"1003\".isdigit()"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "cm height: 176 is all digits = True\n"
+ ]
+ }
+ ],
"source": [
"cm_height = \"176\"\n",
"print(\"cm height:\",cm_height, \"is all digits =\",cm_height.isdigit())"
@@ -2633,9 +3711,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 20,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "False\n",
+ "True\n"
+ ]
+ }
+ ],
"source": [
"print(\"SAVE\".islower())\n",
"print(\"SAVE\".isupper())"
@@ -2643,9 +3730,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 19,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"\"Boolean\".startswith(\"B\")"
]
@@ -2661,28 +3759,53 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 22,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 22,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Use .isalpha() on the string \"alphabetical\"\n",
- "\n"
+ "\"alphabetical\".isalpha()\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 23,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "False"
+ ]
+ },
+ "execution_count": 23,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Use .isalpha() on the string: \"Are spaces and punctuation Alphabetical?\"\n",
- "\n"
+ "\"Are spaces and punctuation Alphabetical?\".isalpha()\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# Module 1 Part 11 - Same items as M1 P10, iterate, try something new\n",
@@ -2708,7 +3831,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -2730,9 +3856,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 24,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "It's time to save your code\n",
+ "I said to the class \"sometimes you need to shut down and restart a notebook when cells refuse to run\"\n"
+ ]
+ }
+ ],
"source": [
"# review and run the code\n",
"\n",
@@ -2754,28 +3889,48 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 25,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Where's the homework\n"
+ ]
+ }
+ ],
"source": [
"# [ ] using a print statement, display the text: Where's the homework?\n",
- "\n"
+ "print(\"Where's the homework\")\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 27,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Education is what remains after one has forgotten what one has learned in school - Albert Einstein\n"
+ ]
+ }
+ ],
"source": [
"# [ ] output with double quotes: \"Education is what remains after one has forgotten what one has learned in school\" - Albert Einstein\n",
- "\n"
+ "albert = \"Education is what remains after one has forgotten what one has learned in school\"\n",
+ "print(albert,\"- Albert Einstein\")\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
">**note:**: Quotes in quotes handles only simple cases of displaying quotation marks. More complex case are covered later under *escape sequences.*"
@@ -2784,7 +3939,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -2821,45 +3979,97 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 28,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 28,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"\"Python\".isalpha()"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 29,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 29,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"\"3rd\".isalnum()"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 30,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 30,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"\"A Cold Stromy Night\".istitle()"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 31,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 31,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"\"1003\".isdigit()"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 32,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "cm height: 176 is all digits = True\n"
+ ]
+ }
+ ],
"source": [
"cm_height = \"176\"\n",
"print(\"cm height:\",cm_height, \"is all digits =\",cm_height.isdigit())"
@@ -2867,9 +4077,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 33,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "False\n",
+ "True\n"
+ ]
+ }
+ ],
"source": [
"print(\"SAVE\".islower())\n",
"print(\"SAVE\".isupper())"
@@ -2877,9 +4096,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 34,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 34,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"\"Boolean\".startswith(\"B\")"
]
@@ -2895,40 +4125,76 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 35,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 35,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Use .isalpha() on the string \"alphabetical\"\n",
- "\n"
+ "\"alphabetical\".isalpha()\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 36,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "False"
+ ]
+ },
+ "execution_count": 36,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] Use .isalpha() on the string: \"Are spaces and punctuation Alphabetical?\"\n",
- "\n"
+ "\"Are spaces and punctuation Alphabetical?\".isalpha()\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 37,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 37,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] initailize variable alpha_test with input\n",
- "\n",
+ "alpha_test = \"Alphabetical\"\n",
"# [ ] use .isalpha() on string variable alpha_test\n",
- "\n"
+ "alpha_test.isalpha()\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# Module 1 Part 12\n",
@@ -2954,7 +4220,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -2979,18 +4248,34 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 38,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Ms. browning is in her office.\n"
+ ]
+ }
+ ],
"source": [
"print(\"ms. Browning is in her office.\".capitalize())"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 39,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Green green green and GREEN!\n"
+ ]
+ }
+ ],
"source": [
"fav_color = \"green\"\n",
"print(fav_color.capitalize(), fav_color, fav_color,\"and\", fav_color.upper()+\"!\")"
@@ -3008,42 +4293,64 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 42,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "PIZZA is the best!\n",
+ "pizza is the best!\n",
+ "PIzZA is the best!\n",
+ "Pizza is the best!\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get input for a variable, fav_food, that describes a favorite food\n",
- "\n",
+ "fav_food = \"piZza\"\n",
"# [ ] display fav_food as ALL CAPS, used in a sentence\n",
- "\n",
+ "print(fav_food.upper(),\"is the best!\")\n",
"\n",
"# [ ] dispaly fav_food as all lower case, used in a sentence\n",
- "\n",
+ "print(fav_food.lower(),\"is the best!\")\n",
"\n",
"# [] display fav_food with swapped case, used in a sentence\n",
- "\n",
+ "print(fav_food.swapcase(),\"is the best!\")\n",
"\n",
"# [] display fav_food with capitalization, used in a sentence\n",
- "\n",
+ "print(fav_food.capitalize(),\"is the best!\")\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 44,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Forest green forest green FOREST GREEN is awesome. fOREST gREEN\n"
+ ]
+ }
+ ],
"source": [
"fav_color = \"Forest Green\"\n",
"# [] display the fav_color variable as upper, lower, swapcase, and capitalize formatting in a single print() statement\n",
- "\n"
+ "print(fav_color.capitalize(),fav_color.lower(),fav_color.upper(),\"is awesome.\",fav_color.swapcase())\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -3056,7 +4363,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
" Example"
@@ -3064,9 +4374,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "What is your favorite color?: green\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "green\n"
+ ]
+ }
+ ],
"source": [
"# review and run code - test a capitalized color input\n",
"fav_color = input('What is your favorite color?: ').lower()\n",
@@ -3084,9 +4409,32 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "BLUE reversed\n",
+ "NBLAH blahblah\n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "What is your favorite color?: green\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Your favorite color in all caps is: GREEN\n"
+ ]
+ }
+ ],
"source": [
"def short_rhyme(r1,r2):\n",
" print(r1.upper(),r2.lower())\n",
@@ -3097,13 +4445,20 @@
"r1 = \"nblah\"\n",
"r2 = \"blahblah\"\n",
"short_rhyme(rh1,rh2)\n",
- "short_rhyme(r1,r2)"
+ "short_rhyme(r1,r2)\n",
+ "# [ ] format input() with .upper()\n",
+ "fav_color = input(\"What is your favorite color?: \").upper()\n",
+ "\n",
+ "print(\"Your favorite color in all caps is:\", fav_color)"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -3123,11 +4478,19 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {
"scrolled": true
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "True\n"
+ ]
+ }
+ ],
"source": [
"# review and run code to test if a string is to be found in another string\n",
"menu = \"salad, pasta, sandwich, pizza, drinks, dessert\"\n",
@@ -3136,9 +4499,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "'hello' in greeting = False\n",
+ "'Hello' in greeting = True\n"
+ ]
+ }
+ ],
"source": [
"# review and run code to test case sensitive examples \n",
"greeting = \"Hello World!\"\n",
@@ -3155,9 +4527,19 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "'hello' in greeting = False\n",
+ "'Hello' in greeting = True\n",
+ "'hello' in greeting if lower used = True\n"
+ ]
+ }
+ ],
"source": [
"# review and run code to test removing case sensitivity from a string comparison\n",
"greeting = \"Hello World!\"\n",
@@ -3179,16 +4561,25 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Pizza in menu = True\n",
+ "Soup in menu = False\n",
+ "Dessert in menu = True\n"
+ ]
+ }
+ ],
"source": [
"# [] print 3 tests, with description text, testing the menu variable for 'pizza', 'soup' and 'dessert'\n",
"menu = \"salad, pasta, sandwich, pizza, drinks, dessert\"\n",
- "\n",
- "result = input(\"What is your name? \")\n",
- "\n",
- "print(\"Your name is\",result.upper())\n"
+ "print(\"Pizza in menu =\", \"pizza\" in menu)\n",
+ "print(\"Soup in menu =\", \"soup\" in menu)\n",
+ "print(\"Dessert in menu =\", \"dessert\" in menu)\n"
]
},
{
@@ -3204,12 +4595,33 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "What item would you like to check? pizza\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Is pizza on the menu? True\n"
+ ]
+ }
+ ],
"source": [
"# Create a program where the user supplies input to search the menu\n",
+ "menu = \"salad, pasta, sandwich, pizza, drinks, dessert\"\n",
+ "\n",
+ "menu_ask = input(\"What item would you like to check? \").lower()\n",
"\n",
+ "is_on_menu = menu_ask in menu.lower()\n",
+ "\n",
+ "print(\"Is\", menu_ask, \"on the menu?\", is_on_menu)\n",
"\n"
]
},
@@ -3229,22 +4641,63 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Our menu includes: salad, pasta, sandwich, pizza, drinks, dessert\n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "What item would you like to add? eggs\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Updated menu: salad, pasta, sandwich, pizza, drinks, dessert, eggs\n"
+ ]
+ }
+ ],
"source": [
"# add to menu\n",
- "\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "print(\"Our menu includes:\",menu)\n",
+ "add_item = input(\"What item would you like to add?\")\n",
+ "new_menu = menu + \",\" + \" \" + add_item\n",
+ "print(\"Updated menu:\",new_menu)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter an item to search for: eggs\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Is eggs available? True\n"
+ ]
+ }
+ ],
"source": [
"# Testing Add to Menu - create user input to search for an item on the new menu\n",
- "\n"
+ "search_item = input(\"Enter an item to search for: \").lower()\n",
+ "print(\"Is\", search_item, \"available?\", search_item in new_menu.lower())\n"
]
},
{
@@ -3258,13 +4711,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 30,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Red in paint colors = True\n"
+ ]
+ }
+ ],
"source": [
"# [ ] fix the error\n",
"paint_colors = \"red, blue, green, black, orange, pink\"\n",
- "print('Red in paint colors = ',red in paint_colors)\n",
+ "print(\"Red in paint colors = \", \"red\" in paint_colors)\n",
"\n"
]
},
@@ -3286,7 +4747,7 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -3300,9 +4761,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.13.1"
+ "version": "3.12.1"
}
},
"nbformat": 4,
- "nbformat_minor": 1
+ "nbformat_minor": 4
}
diff --git a/P1 Python Absolute Beginner/Module_1.1_Practice.ipynb b/P1 Python Absolute Beginner/Module_1.1_Practice.ipynb
index ad652b39..58fdfddf 100644
--- a/P1 Python Absolute Beginner/Module_1.1_Practice.ipynb
+++ b/P1 Python Absolute Beginner/Module_1.1_Practice.ipynb
@@ -3,7 +3,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# P1M1 Module 1 Practice 1\n",
@@ -39,10 +42,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hello!\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(\"Hello!\")"
+ ]
},
{
"cell_type": "markdown",
@@ -55,9 +68,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "watch for the cat\n"
+ ]
+ }
+ ],
"source": [
"print('watch for the cat')"
]
@@ -90,12 +111,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": []
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "This notebook belongs to Matthew Williams, 2/13/26\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(\"This notebook belongs to Matthew Williams, 2/13/26\")"
+ ]
},
{
"cell_type": "markdown",
@@ -108,14 +137,23 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Matt\n",
+ "is using python\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print your name\n",
- "\n",
+ "print(\"Matt\")\n",
"# [ ] print \"is using Python\"\n",
- "\n"
+ "print(\"is using python\")\n"
]
},
{
@@ -138,16 +176,22 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Matt\n"
+ ]
+ }
+ ],
"source": [
"# [ ] create a variable your_name and assign it a sting containing your name\n",
- "\n",
+ "your_name = \"Matt\"\n",
"#[ ] print your_name\n",
- "\n"
+ "print(your_name)\n"
]
},
{
@@ -161,15 +205,25 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rosemary 11.5 7\n"
+ ]
+ }
+ ],
"source": [
"# [ ] create variables and assign values for: favorite_song, shoe_size, lucky_number\n",
- "\n",
+ "favorite_song = \"rosemary\"\n",
+ "shoe_size = \"11.5\"\n",
+ "lucky_number = \"7\"\n",
"\n",
"# [ ] print the value of each variable favorite_song, shoe_size, and lucky_number\n",
- "\n",
+ "print(favorite_song,shoe_size,lucky_number)\n",
"\n"
]
},
@@ -185,18 +239,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "My favorite song is rosemary\n",
+ "My shoe size is 11.5\n",
+ "The luckiest number is 7\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print favorite_song with description\n",
- "\n",
+ "print(\"My favorite song is\",favorite_song)\n",
"\n",
"# [ ] print shoe_size with description\n",
- "\n",
+ "print(\"My shoe size is\",shoe_size)\n",
"\n",
"# [ ] print lucky_number with description\n",
- "\n"
+ "print(\"The luckiest number is\",lucky_number)\n"
]
},
{
@@ -212,13 +276,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "My favorite song is rosemary but it only got to 11.5 on the charts, not #7\n"
+ ]
+ }
+ ],
"source": [
"# assign favorite_lucky_shoe using\n",
- "\n",
- "\n"
+ "favorite_lucky_shoe = \"My favorite song is \" + favorite_song + \" but it only got to \" + shoe_size + \" on the charts, not #\" + lucky_number\n",
+ "print(favorite_lucky_shoe)\n"
]
},
{
@@ -240,19 +312,44 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 23,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "*\n",
+ " *\n",
+ " *\n",
+ " *\n",
+ "**********\n",
+ "* *\n",
+ "**********\n",
+ " * * \n",
+ " \n",
+ " * * \n",
+ " *** \n"
+ ]
+ }
+ ],
"source": [
"# [ ] print a diagonal using \"*\"\n",
- "\n",
+ "print(\"*\")\n",
+ "print(\" *\")\n",
+ "print(\" *\")\n",
+ "print(\" *\")\n",
"\n",
"# [ ] rectangle using \"*\"\n",
- "\n",
+ "print(\"**********\")\n",
+ "print(\"* *\")\n",
+ "print(\"**********\")\n",
"\n",
"# [ ] smiley using \"*\"\n",
- "\n",
- "\n"
+ "print(\" * * \")\n",
+ "print(\" \")\n",
+ "print(\" * * \")\n",
+ "print(\" *** \")\n"
]
},
{
@@ -265,89 +362,177 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 24,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 24,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of 'your name' (use single quotes)\n",
- "\n",
+ "type('your name')\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 25,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of \"save your notebook!\" (use double quotes)\n",
- "\n",
+ "type(\"save your notebook!\")\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 26,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 26,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of \"25\" (use quotes)\n",
- "\n",
+ "type(\"25\")\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 27,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 27,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of \"save your notebook \" + 'your name'\n",
- "\n",
+ "type(\"save your notebook \" + 'your name')\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 28,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "int"
+ ]
+ },
+ "execution_count": 28,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of 25 (no quotes)\n",
- "\n",
+ "type(25)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 29,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "int"
+ ]
+ },
+ "execution_count": 29,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of 25 + 10 \n",
- "\n",
+ "type(25 + 10)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 30,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "float"
+ ]
+ },
+ "execution_count": 30,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of 1.55\n",
- "\n",
+ "type(1.55)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 31,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "float"
+ ]
+ },
+ "execution_count": 31,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of 1.55 + 25\n",
- "\n",
+ "type(1.55 + 25)\n",
"\n"
]
},
@@ -362,10 +547,8 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 33,
+ "metadata": {},
"outputs": [],
"source": [
"# assignments ***RUN THIS CELL*** before starting the section\n",
@@ -378,77 +561,143 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 34,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 34,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the current type of the variable student_name\n",
- "\n",
+ "type(student_name)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 35,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "int"
+ ]
+ },
+ "execution_count": 35,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of student_age\n",
- "\n",
+ "type(student_age)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 36,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "float"
+ ]
+ },
+ "execution_count": 36,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of student_grade\n",
- "\n",
+ "type(student_grade)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 37,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "float"
+ ]
+ },
+ "execution_count": 37,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the type of student_age + student_grade\n",
- "\n",
+ "type(student_age + student_grade)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 38,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 38,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] display the current type of student_id\n",
- "\n",
+ "type(student_id)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 39,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
"source": [
"# assign new value to student_id \n",
- "\n",
+ "student_id = 3\n",
"\n",
"# [ ] display the current of student_id\n",
- "\n",
+ "print(type(student_id))\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"#### number integer addition\n",
@@ -458,14 +707,14 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 40,
+ "metadata": {},
"outputs": [],
"source": [
"# [ ] create integer variables (x, y, z) and assign them 1-3 digit integers (no decimals - no quotes)\n",
- "\n",
+ "x = 1\n",
+ "y = 2\n",
+ "z = 3\n",
"\n"
]
},
@@ -480,12 +729,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 42,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "6\n"
+ ]
+ }
+ ],
"source": [
- "\n",
- "\n"
+ "xyz_sum = x + y + z\n",
+ "print(xyz_sum)\n"
]
},
{
@@ -498,56 +755,89 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 43,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hello World!\n"
+ ]
+ }
+ ],
"source": [
"# [ ] fix the error \n",
"\n",
- "print(\"Hello World!\"\") \n",
+ "print(\"Hello World!\") \n",
"\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 44,
"metadata": {},
- "outputs": [],
- "source": [
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "strings have quotes and variables have names\n"
+ ]
+ }
+ ],
+ "source": [
"# [ ] fix the error \n",
- "print(strings have quotes and variables have names)\n",
+ "print(\"strings have quotes and variables have names\")\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
+ "execution_count": 46,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "I have $5\n"
+ ]
+ }
+ ],
"source": [
"# [ ] fix the error \n",
- "print( \"I have $\" + 5)\n",
+ "print( \"I have $\" + \"5\")\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 47,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "always save the notebook\n"
+ ]
+ }
+ ],
"source": [
"# [ ] fix the error \n",
- "print('always save the notebook\")\n",
+ "print(\"always save the notebook\")\n",
" \n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"## ASCII art\n",
@@ -557,23 +847,57 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 48,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "M M W W\n",
+ "MM MM W W \n",
+ "M M M M W W W \n",
+ "M M M W W W W \n",
+ "M M W W \n"
+ ]
+ }
+ ],
"source": [
"# [ ] ASCII ART\n",
- "\n",
+ "# [ ] ASCII ART for initials\n",
+ "print(\"M M W W\")\n",
+ "print(\"MM MM W W \")\n",
+ "print(\"M M M M W W W \")\n",
+ "print(\"M M M W W W W \")\n",
+ "print(\"M M W W \")\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 49,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ " /\\ \n",
+ " / \\ \n",
+ " /____\\ \n",
+ " | [] | \n",
+ " |____| \n"
+ ]
+ }
+ ],
"source": [
"# [ ] ASCII ART\n",
- "\n"
+ "# [ ] Challenge: ASCII Picture\n",
+ "print(\" /\\\\ \")\n",
+ "print(\" / \\\\ \")\n",
+ "print(\" /____\\\\ \")\n",
+ "print(\" | [] | \")\n",
+ "print(\" |____| \")\n"
]
},
{
@@ -600,27 +924,50 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {
"scrolled": true
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Remind me to: eat\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "eat\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get user input for a variable named remind_me\n",
- "\n",
+ "remind_me = input(\"Remind me to: \")\n",
"\n",
"# [ ] print the value of the variable remind_me\n",
- "\n"
+ "print(remind_me)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 51,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Remember, 10\n"
+ ]
+ }
+ ],
"source": [
"# use string addition to print \"remember: \" before the remind_me input string\n",
- "\n"
+ "print(\"Remember,\",remind_me)\n"
]
},
{
@@ -639,23 +986,43 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 54,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "What is the meeting subject? grad party\n",
+ "What is the meeting time? 7:00PM\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Meeting Subject: grad party\n",
+ "Meeting Time: 7:00PM\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get user input for 2 variables: meeting_subject and meeting_time\n",
- "\n",
- "\n",
+ "meeting_subject = input(\"What is the meeting subject? \")\n",
+ "meeting_time = input(\"What is the meeting time? \")\n",
"# [ ] use string addition to print meeting subject and time with labels\n",
- "\n",
- "\n",
+ "print(\"Meeting Subject:\",meeting_subject)\n",
+ "print(\"Meeting Time:\",meeting_time)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"## print() formatting \n",
@@ -664,38 +1031,65 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 56,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Wednesday is in the middle of the week.\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print the combined strings \"Wednesday is\" and \"in the middle of the week\" \n",
- "\n"
+ "print(\"Wednesday is\",\"in the middle of the week.\")\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Remember to eat\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print combined string \"Remember to\" and the string variable remind_me from input above\n",
- "\n"
+ "print(\"Remember to\",remind_me)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "I like to eat and my shoe size is 11.5 but my luckiest number is 7\n"
+ ]
+ }
+ ],
"source": [
"# [ ] Combine 3 variables from above with multiple strings\n",
- "\n"
+ "print(\"I like to\",remind_me, \"and my shoe size is\", shoe_size, \"but my luckiest number is\", lucky_number)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"### print() quotation marks"
@@ -703,30 +1097,50 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "It's a great day to practice Python!\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print a string sentence that will display an Apostrophe (')\n",
- "\n",
+ "print(\"It's a great day to practice Python!\")\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\"I like to eat\" bananas.\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print a string sentence that will display a quote(\") or quotes\n",
- "\n",
+ "albert_quote = '\"I like to eat\"'\n",
+ "print(albert_quote,\"bananas.\")\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"## Boolean string tests"
@@ -748,32 +1162,73 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter a type of vehicle: Mustang\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "All Alpha: True\n",
+ "Alphanumeric: True\n",
+ "Is Capitalized: True\n",
+ "Is Lowercase: False\n"
+ ]
+ }
+ ],
"source": [
"# [ ] complete vehicle tests \n",
+ "vehicle = input(\"Enter a type of vehicle: \")\n",
"\n",
- "\n",
+ "print(\"All Alpha:\", vehicle.isalpha())\n",
+ "print(\"Alphanumeric:\", vehicle.isalnum())\n",
+ "print(\"Is Capitalized:\", vehicle.istitle())\n",
+ "print(\"Is Lowercase:\", vehicle.islower())\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter a color: Red\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Starts with 'b': False\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print True or False if color starts with \"b\" \n",
- "\n"
+ "color = input(\"Enter a color: \")\n",
+ "print(\"Starts with 'b':\", color.lower().startswith(\"b\"))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"outputs": [],
"source": []
@@ -787,57 +1242,110 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The time is noon.\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print the string variable capital_this Capitalizing only the first letter\n",
"capitalize_this = \"the TIME is Noon.\"\n",
- "\n"
+ "print(capitalize_this.capitalize())\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Who WRITES like This?\n"
+ ]
+ }
+ ],
"source": [
"# print the string variable swap_this in swapped case\n",
"swap_this = \"wHO writes LIKE tHIS?\"\n",
- "\n"
+ "print(swap_this.swapcase())\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "can you hear me?\n"
+ ]
+ }
+ ],
"source": [
"# print the string variable whisper_this in all lowercase\n",
"whisper_this = \"Can you hear me?\"\n",
- "\n"
+ "print(whisper_this.lower())\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "CAN YOU HEAR ME NOW!?\n"
+ ]
+ }
+ ],
"source": [
"# print the string variable yell_this in all UPPERCASE\n",
"yell_this = \"Can you hear me Now!?\"\n",
- "\n"
+ "print(yell_this.upper())\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 21,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "enter a string to reformat: Mustang\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Uppercase: MUSTANG\n",
+ "Lowercase: mustang\n",
+ "Swapcase: mUSTANG\n",
+ "Capitalized: Mustang\n"
+ ]
+ }
+ ],
"source": [
"#format input using .upper(), .lower(), .swapcase, .capitalize()\n",
"format_input = input('enter a string to reformat: ')\n",
- "\n"
+ "print(\"Uppercase:\", format_input.upper())\n",
+ "print(\"Lowercase:\", format_input.lower())\n",
+ "print(\"Swapcase:\", format_input.swapcase())\n",
+ "print(\"Capitalized:\", format_input.capitalize())\n"
]
},
{
@@ -849,41 +1357,92 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 22,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter a color: Red\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "red\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get user input for a variable named color\n",
"# [ ] modify color to be all lowercase and print\n",
- "\n"
+ "color = input(\"Enter a color: \").lower()\n",
+ "print(color)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 23,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter a reminder: To eat\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "to eat\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get user input using variable remind_me and format to all **lowercase** and print\n",
"# [ ] test using input with mixed upper and lower cases\n",
- "\n"
+ "remind_me = input(\"Enter a reminder: \").lower()\n",
+ "print(remind_me)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 24,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "What do you want to yell? matt\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "MATT\n"
+ ]
+ }
+ ],
"source": [
"# [] get user input for the variable yell_this and format as a \"YELL\" to ALL CAPS\n",
- "\n"
+ "yell_this = input(\"What do you want to yell? \").upper()\n",
+ "print(yell_this)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"outputs": [],
"source": []
@@ -898,34 +1457,63 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 25,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "List some animals: Cat, dog\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Is 'cat' in your list? True\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get user input for the name of some animals in the variable animals_input\n",
- "\n",
+ "animals_input = input(\"List some animals: \").lower()\n",
"\n",
"# [ ] print true or false if 'cat' is in the string variable animals_input\n",
- "\n"
+ "print(\"Is 'cat' in your list?\", \"cat\" in animals_input)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter a color: Red\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Starts with 'b': False\n",
+ "The original color entered was: Red\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get user input for color\n",
- "\n",
+ "color_test = input(\"Enter a color: \")\n",
"\n",
"# [ ] print True or False for starts with \"b\"\n",
- "\n",
+ "print(\"Starts with 'b':\", color_test.lower().startswith(\"b\"))\n",
"\n",
"# [ ] print color variable value exactly as input \n",
"# test with input: \"Blue\", \"BLUE\", \"bLUE\"\n",
- "\n",
+ "print(\"The original color entered was:\", color_test)\n",
"\n",
"\n"
]
@@ -951,20 +1539,36 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 27,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter a type of reading material (e.g. blog): blog\n",
+ "Enter three things you can read: Book, blog, catalog\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "item found = True\n"
+ ]
+ }
+ ],
"source": [
"# project: \"guess what I'm reading\"\n",
"\n",
"# 1[ ] get 1 word input for can_read variable\n",
- "\n",
+ "can_read = input(\"Enter a type of reading material (e.g. blog): \").lower()\n",
"\n",
"# 2[ ] get 3 things input for can_read_things variable\n",
- "\n",
+ "can_read_things = input(\"Enter three things you can read: \").lower()\n",
"\n",
"# 3[ ] print True if can_read is in can_read_things\n",
- "\n",
+ "print(\"item found =\", can_read in can_read_things)\n",
"\n",
"# [] challenge: format the output to read \"item found = True\" (or false)\n",
"# hint: look print formatting exercises\n",
@@ -990,14 +1594,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 37,
"metadata": {},
"outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Give me a food to test: nUts\n"
+ ]
+ },
{
"name": "stdout",
"output_type": "stream",
"text": [
- "True\n"
+ "False\n",
+ "True\n",
+ "Seafood check: False\n",
+ "Chocolate check: False\n"
]
}
],
@@ -1005,7 +1619,7 @@
"# Allergy check \n",
"\n",
"# 1[ ] get input for test (prompt user to enter something like \"nuts\" or \"dairy\" to store in variable named \"test\")\n",
- "test_food = input(\"Give me a food to test: \")\n",
+ "test_food = input(\"Give me a food to test: \").lower()\n",
"\n",
"\n",
"# 2/3[ ] print True if \"dairy\" is in the input or False if not\n",
@@ -1014,9 +1628,9 @@
"# 4[ ] Check if \"nuts\" are in the input\n",
"print(\"nuts\" in test_food)\n",
"# 4+[ ] Challenge: Check if \"seafood\" is in the input\n",
- "\n",
+ "print(\"Seafood check:\", \"seafood\" in test_food)\n",
"# 4+[ ] Challenge: Check if \"chocolate\" is in the input\n",
- "\n"
+ "print(\"Chocolate check:\", \"chocolate\" in test_food)\n"
]
},
{
@@ -1030,7 +1644,7 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -1044,9 +1658,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.13.1"
+ "version": "3.12.1"
}
},
"nbformat": 4,
- "nbformat_minor": 1
+ "nbformat_minor": 4
}
diff --git a/P1 Python Absolute Beginner/Module_1.2_Required_Code.ipynb b/P1 Python Absolute Beginner/Module_1.2_Required_Code.ipynb
index be0b3c0e..342f5a0f 100644
--- a/P1 Python Absolute Beginner/Module_1.2_Required_Code.ipynb
+++ b/P1 Python Absolute Beginner/Module_1.2_Required_Code.ipynb
@@ -4,7 +4,10 @@
"attachments": {},
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# P1M1: Module 1 Required Coding Activity \n",
@@ -33,25 +36,42 @@
},
{
"cell_type": "code",
- "execution_count": 1,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
+ "execution_count": 18,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Names of people met in past 24 hours: Josh, Matt, Seth, jOhn\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "josh, matt, seth, john\n",
+ "John met? True\n",
+ "Matt met? True\n",
+ "Josh met? True\n",
+ "Seth met? True\n"
+ ]
+ }
+ ],
"source": [
"# Create name check code\n",
- "\n",
+ "input_test = input(\"Names of people met in past 24 hours: \").lower()\n",
"# [ ] get input for input_test variable\n",
- "\n",
+ "print(input_test)\n",
"# [ ] print \"True\" message if \"John\" is in the input or False message if not\n",
- "\n",
+ "print(\"John met?\", \"john\" in input_test)\n",
"\n",
"# [ ] print True message if your name is in the input or False if not\n",
- "\n",
+ "print(\"Matt met?\", \"matt\" in input_test)\n",
"\n",
"# [ ] Challenge: Check if another person's name is in the input - print message\n",
- "\n",
- "\n",
+ "print(\"Josh met?\", \"josh\" in input_test)\n",
+ "print(\"Seth met?\", \"seth\" in input_test)\n",
"# [ ] Challenge: Check if a fourth person's name is in the input - print message"
]
},
@@ -65,7 +85,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -79,9 +99,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.8"
+ "version": "3.12.1"
}
},
"nbformat": 4,
- "nbformat_minor": 1
+ "nbformat_minor": 4
}
diff --git a/P1 Python Absolute Beginner/Module_2.0_Tutorials_Functions.ipynb b/P1 Python Absolute Beginner/Module_2.0_Tutorials_Functions.ipynb
index fc779996..4be7d3ce 100644
--- a/P1 Python Absolute Beginner/Module_2.0_Tutorials_Functions.ipynb
+++ b/P1 Python Absolute Beginner/Module_2.0_Tutorials_Functions.ipynb
@@ -49,18 +49,34 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hello World! I am sending string arguments to print \n"
+ ]
+ }
+ ],
"source": [
"print('Hello World!', 'I am sending string arguments to print ')"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hiroto Yamaguchi will be in the class for 17 year old students.\n"
+ ]
+ }
+ ],
"source": [
"student_age = 17\n",
"student_name = \"Hiroto Yamaguchi\"\n",
@@ -69,9 +85,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "line 1\n",
+ "line 2\n",
+ "\n",
+ "line 4\n"
+ ]
+ }
+ ],
"source": [
"print(\"line 1\")\n",
"print(\"line 2\")\n",
@@ -94,21 +121,33 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hiroto Yamaguchi will be in the class for 17 year old students who like to eat sushi and bananas.\n"
+ ]
+ }
+ ],
"source": [
"#[ ] increase the number of arguments used in print() to 8 or more \n",
"student_age = 17\n",
"student_name = \"Hiroto Yamaguchi\"\n",
- "print(student_name,'will be in the class for',student_age, 'year old students.')\n",
+ "food = \"sushi\"\n",
+ "print(student_name,'will be in the class for',student_age, 'year old students','who like to eat',food,'and','bananas.')\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -153,9 +192,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hello there!\n",
+ "goodbye\n"
+ ]
+ }
+ ],
"source": [
"# defines a function named say_hi\n",
"def say_hi(): #defining the function\n",
@@ -166,7 +214,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@@ -177,9 +225,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "33\n"
+ ]
+ }
+ ],
"source": [
"three_three()"
]
@@ -205,9 +261,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hello there!\n",
+ "goodbye\n",
+ "\n",
+ "33\n"
+ ]
+ }
+ ],
"source": [
"# Program defines and calls the say_hi & three_three functions\n",
"# [ ] review and run the code\n",
@@ -244,11 +311,23 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "PYTHON IS FUN!\n"
+ ]
+ }
+ ],
"source": [
- "#[ ] define (def) a simple function called yell_it() and call the function\n"
+ "#[ ] define (def) a simple function called yell_it() and call the function\n",
+ "def yell_it():\n",
+ " phrase = \"python is fun\"\n",
+ " print(phrase.upper() + \"!\")\n",
+ "yell_it()"
]
},
{
@@ -295,9 +374,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "IT IS TIME TO SAVE THE NOTEBOOK!\n"
+ ]
+ }
+ ],
"source": [
"# yell_this() yells the string Argument provided\n",
"def yell_this(phrase):\n",
@@ -309,9 +396,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hi\n",
+ "Bye\n"
+ ]
+ }
+ ],
"source": [
"# use a default argument\n",
"def say_this(phrase = \"Hi\"): \n",
@@ -336,16 +432,32 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter words to yell: hi\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "HI!\n"
+ ]
+ }
+ ],
"source": [
"# [ ] define yell_this() \n",
- "\n",
+ "def yell_this(phrase):\n",
+ " print(phrase.upper() + \"!\")\n",
"# [ ] get user input in variable words_to_yell\n",
- "\n",
+ "words_to_yell = input(\"Enter words to yell: \")\n",
"# [ ] call yell_this function with words_to_yell as argument\n",
- "\n"
+ "yell_this(words_to_yell)\n"
]
},
{
@@ -404,9 +516,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 11,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "let's go let's go let's go let's go\n"
+ ]
+ }
+ ],
"source": [
"# Message double returns the string Argument doubled\n",
"def msg_double(phrase):\n",
@@ -420,9 +540,27 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Save Now! Save Now!\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "str"
+ ]
+ },
+ "execution_count": 12,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# example of functions with return values used in functions\n",
"def msg_double(phrase):\n",
@@ -457,13 +595,16 @@
"outputs": [],
"source": [
"# create and call make_doctor() with full_name argument from user input - then print the return value\n",
- "\n"
+ "make_doctor(\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -475,7 +616,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"\n",
@@ -486,9 +630,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "SCHEDULE: [1st] Mathematics, [2nd] History\n"
+ ]
+ }
+ ],
"source": [
"def make_schedule(period1, period2):\n",
" schedule = (\"[1st] \" + period1.title() + \", [2nd] \" + period2.title())\n",
@@ -501,7 +653,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"\n",
@@ -517,13 +672,25 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "SCHEDULE: [1st] Mathematics, [2nd] History, [3rd] Science\n"
+ ]
+ }
+ ],
"source": [
"# [ ] add a 3rd period parameter to make_schedule\n",
+ "def make_schedule(period1, period2, period3):\n",
+ " schedule = (\"[1st] \" + period1.title() + \", [2nd] \" + period2.title() + \", [3rd] \" + period3.title())\n",
+ " return schedule\n",
+ "student_schedule = make_schedule(\"mathematics\", \"history\", \"science\")\n",
"# [ ] Optional - print a schedule for 6 classes (Tip: perhaps let the function make this easy)\n",
- "\n"
+ "print(\"SCHEDULE:\", student_schedule)\n"
]
},
{
@@ -588,9 +755,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "hat available is True\n"
+ ]
+ }
+ ],
"source": [
"# review and run code - note: fix error in the following \"tasks\" section\n",
"def hat_available(color):\n",
@@ -616,18 +791,14 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 7,
"metadata": {},
"outputs": [
{
- "ename": "NameError",
- "evalue": "name 'hat_available' is not defined",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# [ ] fix the sequence of the code to remove the NameError\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mhave_hat\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mhat_available\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'green'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'hat available is'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhave_hat\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mNameError\u001b[0m: name 'hat_available' is not defined"
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "hat available is True\n"
]
}
],
@@ -678,24 +849,44 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter a bird name to check for availability: crow\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "crow availability is True\n"
+ ]
+ }
+ ],
"source": [
"# [ ] create function bird_available\n",
- "\n",
+ "def bird_available(bird_type):\n",
+ " bird_types = 'crow robin parrot eagle sandpiper hawk pigeon'\n",
+ " return (bird_type.lower() in bird_types)\n",
"# [ ] user input\n",
- "\n",
+ "user_bird = input(\"Enter a bird name to check for availability: \")\n",
"# [ ] call bird_available\n",
- "\n",
+ "is_available = bird_available(user_bird)\n",
"# [ ] print availbility status\n",
- "\n"
+ "print(user_bird, \"availability is\", is_available)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"\n",
@@ -705,12 +896,27 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "enter how many you want: 10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "10 will be ordered\n"
+ ]
+ }
+ ],
"source": [
"# define function how_many\n",
- "how_many():\n",
+ "def how_many():\n",
" requested = input(\"enter how many you want: \")\n",
" return requested\n",
"\n",
@@ -731,7 +937,7 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -745,9 +951,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.8"
+ "version": "3.12.1"
}
},
"nbformat": 4,
- "nbformat_minor": 1
+ "nbformat_minor": 4
}
diff --git a/P1 Python Absolute Beginner/Module_2.1_Practice.ipynb b/P1 Python Absolute Beginner/Module_2.1_Practice.ipynb
index 8f9938a5..0931dec5 100644
--- a/P1 Python Absolute Beginner/Module_2.1_Practice.ipynb
+++ b/P1 Python Absolute Beginner/Module_2.1_Practice.ipynb
@@ -24,46 +24,102 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Python is great,\n",
+ "I ate cake,\n"
+ ]
+ }
+ ],
"source": [
"# [ ] define and call a function short_rhyme() that prints a 2 line rhyme\n",
- "\n"
+ "def short_rhyme():\n",
+ " print(\"Python is great,\")\n",
+ " print(\"I ate cake,\")\n",
+ "short_rhyme()"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Welcome To Python Programming\n"
+ ]
+ }
+ ],
"source": [
"# [ ] define (def) a simple function: title_it() and call the function\n",
"# - has a string parameter: msg\n",
"# - prints msg in Title Case\n",
- "\n"
+ "def title_it(msg):\n",
+ " print(msg.title())\n",
+ "title_it(\"welcome to python programming\")\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "what is the title? Matt\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Matt\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get user input with prompt \"what is the title?\" \n",
"# [ ] call title_it() using input for the string argument\n",
- "\n"
+ "user_title = input(\"what is the title? \")\n",
+ "title_it(user_title)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "what is the title? Matt\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Matt\n"
+ ]
+ }
+ ],
"source": [
"# [ ] define title_it_rtn() which returns a titled string instead of printing\n",
"# [ ] call title_it_rtn() using input for the string argumetnt and print the result\n",
- "\n"
+ "def title_it_rtn(msg):\n",
+ " return msg.title()\n",
+ "user_title = input(\"what is the title? \")\n",
+ "print(title_it_rtn(user_title))\n"
]
},
{
@@ -82,33 +138,34 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 6,
"metadata": {},
"outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter the book title: Adventures\n",
+ "Enter the price: $20\n"
+ ]
+ },
{
"name": "stdout",
"output_type": "stream",
"text": [
- "\n",
- "\n",
- "\n",
- "D\n"
+ "Title: Adventures, costs $$20\n"
]
}
],
"source": [
"# [ ] create, call and test bookstore() function\n",
- "def bookstore():\n",
- " return \"This book costs $25.\"\n",
+ "def bookstore(book, price):\n",
+ " book_title = title_it_rtn(book)\n",
+ " return \"Title: \" + book_title + \", costs $\" + price\n",
"\n",
- "var1 = ()\n",
- "var2 = []\n",
- "var3 = {}\n",
- "print(type(var1))\n",
- "print(type(var2))\n",
- "print(type(var3))\n",
- "my_string = \"Dominic\"\n",
- "print(my_string[0])"
+ "book_entry = input(\"Enter the book title: \")\n",
+ "price_entry = input(\"Enter the price: \")\n",
+ "print(bookstore(book_entry, price_entry))"
]
},
{
@@ -120,18 +177,22 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 7,
"metadata": {},
"outputs": [
{
- "ename": "NameError",
- "evalue": "name 'get_name' is not defined",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
- "Cell \u001b[0;32mIn[3], line 5\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m (greeting \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m \u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m+\u001b[39m name \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m!\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 4\u001b[0m \u001b[38;5;66;03m# get name and greeting, send to make_greeting \u001b[39;00m\n\u001b[0;32m----> 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(make_greeting(\u001b[43mget_name\u001b[49m(), get_greeting()))\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21mget_name\u001b[39m():\n\u001b[1;32m 8\u001b[0m name_entry \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124menter a name: \u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
- "\u001b[0;31mNameError\u001b[0m: name 'get_name' is not defined"
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "enter a name: Matt\n",
+ "enter a greeting: Hi\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hi Matt!\n"
]
}
],
@@ -140,7 +201,6 @@
" return (greeting + \" \" + name + \"!\")\n",
"\n",
"# get name and greeting, send to make_greeting \n",
- "print(make_greeting(get_name(), get_greeting()))\n",
"\n",
"def get_name():\n",
" name_entry = input(\"enter a name: \")\n",
@@ -150,7 +210,7 @@
" greeting_entry = input(\"enter a greeting: \")\n",
" return greeting_entry\n",
"\n",
- "\n",
+ "print(make_greeting(get_name(), get_greeting()))\n",
"\n"
]
},
@@ -166,7 +226,7 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -180,9 +240,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.13.1"
+ "version": "3.12.1"
}
},
"nbformat": 4,
- "nbformat_minor": 1
+ "nbformat_minor": 4
}
diff --git a/P1 Python Absolute Beginner/Module_2.2_Required_Code.ipynb b/P1 Python Absolute Beginner/Module_2.2_Required_Code.ipynb
index 911c7345..08298ce7 100644
--- a/P1 Python Absolute Beginner/Module_2.2_Required_Code.ipynb
+++ b/P1 Python Absolute Beginner/Module_2.2_Required_Code.ipynb
@@ -4,7 +4,10 @@
"attachments": {},
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# P1M2: Module 2 Required Coding Activity\n",
@@ -26,14 +29,34 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter the fish type: Bass\n",
+ "Enter the price: 20\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Report for Matthew Williams. Fish Type: Bass costs $20\n"
+ ]
+ }
+ ],
"source": [
"# [ ] create, call and test fishstore() function \n",
- "name = \"Dominic Thomas\"\n",
- "\n",
- "print(\"Hi\", name, \"fish costs...\")"
+ "def fishstore(fish, price):\n",
+ " # Returns a string in sentence form\n",
+ " return \"Fish Type: \" + fish + \" costs $\" + price\n",
+ "fish_entry = input(\"Enter the fish type: \")\n",
+ "price_entry = input(\"Enter the price: \")\n",
+ "report = fishstore(fish_entry, price_entry)\n",
+ "print(\"Report for Matthew Williams. \" + report)"
]
},
{
@@ -46,7 +69,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -60,9 +83,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.8"
+ "version": "3.12.1"
}
},
"nbformat": 4,
- "nbformat_minor": 1
+ "nbformat_minor": 4
}
diff --git a/P1 Python Absolute Beginner/Module_3.0_Tutorials_Conditionals.ipynb b/P1 Python Absolute Beginner/Module_3.0_Tutorials_Conditionals.ipynb
index 12292b89..e1f71d35 100644
--- a/P1 Python Absolute Beginner/Module_3.0_Tutorials_Conditionals.ipynb
+++ b/P1 Python Absolute Beginner/Module_3.0_Tutorials_Conditionals.ipynb
@@ -45,9 +45,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "True means do something\n"
+ ]
+ }
+ ],
"source": [
"if True:\n",
" print(\"True means do something\")\n",
@@ -57,9 +65,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "enjoy some hot tea!\n"
+ ]
+ }
+ ],
"source": [
"hot_tea = True\n",
"\n",
@@ -71,9 +87,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "pass executed\n"
+ ]
+ }
+ ],
"source": [
"someone_i_know = False\n",
"if someone_i_know:\n",
@@ -86,9 +110,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "how have you been?\n"
+ ]
+ }
+ ],
"source": [
"# changed the value of someone_i_know\n",
"someone_i_know = True\n",
@@ -101,7 +133,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
" Task 1\n",
@@ -114,9 +149,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "It is not sunny.\n"
+ ]
+ }
+ ],
"source": [
"sunny_today = False\n",
"# [ ] test if it is sunny_today and give proper responses using if and else\n",
@@ -128,13 +171,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "It is not sunny.\n"
+ ]
+ }
+ ],
"source": [
"sunny_today = False\n",
"# [ ] use code you created above and test sunny_today = False\n",
- "\n"
+ "if sunny_today:\n",
+ " print(\"It is sunny.\")\n",
+ "else:\n",
+ " print(\"It is not sunny.\")\n"
]
},
{
@@ -165,9 +219,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter the title of a favorite book: Matt\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Matt - nice capitalization in that title!\n"
+ ]
+ }
+ ],
"source": [
"# review code and run cell\n",
"favorite_book = input(\"Enter the title of a favorite book: \")\n",
@@ -180,9 +249,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "enter a positive integer number: 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1 is a positive integer\n"
+ ]
+ }
+ ],
"source": [
"# review code and run cell\n",
"a_number = input(\"enter a positive integer number: \")\n",
@@ -201,9 +285,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "\"enter a type of vehicle that starts with \"P\": Porchw\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Porchw starts with \"P\"\n"
+ ]
+ }
+ ],
"source": [
"# review code and run cell\n",
"vehicle_type = input('\"enter a type of vehicle that starts with \"P\": ')\n",
@@ -217,7 +316,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"\n",
@@ -230,14 +332,33 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "'welcome' is all lower case.\n",
+ "'I have $3' is all lower case.\n",
+ "'I have $3' is not all lower case.\n"
+ ]
+ }
+ ],
"source": [
"test_string_1 = \"welcome\"\n",
"test_string_2 = \"I have $3\"\n",
"# [ ] use if, else to test for islower() for the 2 strings\n",
- "\n"
+ "if test_string_1.islower():\n",
+ " print(f\"'{test_string_1}' is all lower case.\")\n",
+ "else:\n",
+ " print(f\"'{test_string_1}' is not all lower case.\")\n",
+ "print(f\"'{test_string_2}' is all lower case.\")\n",
+ "\n",
+ "if test_string_2.islower():\n",
+ " print(f\"'{test_string_2}' is all lower case.\")\n",
+ "else:\n",
+ " print(f\"'{test_string_2}' is not all lower case.\")"
]
},
{
@@ -252,9 +373,19 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "True\n",
+ "False\n",
+ "False\n"
+ ]
+ }
+ ],
"source": [
"test_string_1 = \"welcome\"\n",
"test_string_2 = \"I have $3\"\n",
@@ -315,9 +446,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "False"
+ ]
+ },
+ "execution_count": 17,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] review and run code to see if 3 greater than 5\n",
"3 > 5"
@@ -325,9 +467,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 18,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] review and run code to see if 3 less than or equal to 5\n",
"3 <= 5"
@@ -335,9 +488,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "False"
+ ]
+ },
+ "execution_count": 19,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] review and run code \n",
"\n",
@@ -350,9 +514,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 20,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "x not equal 9 is True\n",
+ "x equal 3 is True\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run code \n",
"x = 3\n",
@@ -363,7 +536,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"\n",
@@ -387,18 +563,33 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 22,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "False\n"
+ ]
+ }
+ ],
"source": [
"# [ ] create a test to print True or False for 3 + 3 is greater than 2 + 4\n",
- "\n"
+ "if (3 + 3) > (2 + 4):\n",
+ " print(True)\n",
+ "else:\n",
+ " print(False)\n",
+ " \n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -419,9 +610,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 23,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "x was 21\n",
+ "now x is 25\n"
+ ]
+ }
+ ],
"source": [
"# review code and run cell\n",
"x = 21\n",
@@ -435,9 +635,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 24,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "25\n",
+ "Pass: x + 18 is equal to 36\n"
+ ]
+ }
+ ],
"source": [
"# review code and run cell\n",
"print(x)\n",
@@ -450,9 +659,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 25,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "x is 18\n"
+ ]
+ }
+ ],
"source": [
"# review code and run cell. \"!\" means \"not\"\n",
"x = 18\n",
@@ -465,15 +682,23 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 31,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\"==\" tests for, is equal to\n"
+ ]
+ }
+ ],
"source": [
"# review code and run cell\n",
"# DON'T ASSIGN (x = 2) when you mean to COMPARE (x == 2)\n",
"x = 2\n",
"\n",
- "if x = 2:\n",
+ "if x == 2:\n",
" print('\"==\" tests for, is equal to')\n",
"else:\n",
" pass"
@@ -482,7 +707,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"\n",
@@ -492,15 +720,27 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 42,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "y greater than or equal x + x is True\n"
+ ]
+ }
+ ],
"source": [
"# [ ] create an if/else statement that tests if y is greater than or equal x + x \n",
"# [ ] print output: \"y greater than or equal x + x is\" True/False ...or a similar output\n",
"x = 3\n",
"y = x + 8\n",
- "\n"
+ "\n",
+ "if y >= (x + x):\n",
+ " print(\"y greater than or equal x + x is True\")\n",
+ "else:\n",
+ " print(\"y greater than or equal x + x is False\")"
]
},
{
@@ -546,9 +786,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 43,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "False"
+ ]
+ },
+ "execution_count": 43,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# review and run code\n",
"\"hello\" < \"Hello\""
@@ -556,9 +807,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 44,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "False"
+ ]
+ },
+ "execution_count": 44,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# review and run code\n",
"\"Aardvark\" > \"Zebra\""
@@ -566,9 +828,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 45,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 45,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# review and run code\n",
"'student' != 'Student'"
@@ -576,9 +849,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 46,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "'student' >= 'Student' is True\n",
+ "'Student' != 'Student' is False\n"
+ ]
+ }
+ ],
"source": [
"# review and run code\n",
"print(\"'student' >= 'Student' is\", 'student' >= 'Student')\n",
@@ -587,9 +869,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 47,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 47,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# review and run code\n",
"\"Hello \" + \"World!\" == \"Hello World!\""
@@ -606,25 +899,49 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 48,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "True\n"
+ ]
+ }
+ ],
"source": [
"msg = \"Hello\"\n",
"# [ ] print the True/False results of testing if msg string equals \"Hello\" string\n",
- "\n"
+ "print(msg == \"Hello\")\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 50,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Say \"Hello\": Hello\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "True\n"
+ ]
+ }
+ ],
"source": [
"greeting = \"Hello\"\n",
"# [ ] get input for variable named msg, and ask user to 'Say \"Hello\"'\n",
+ "msg = input('Say \"Hello\": ')\n",
"# [ ] print the results of testing if msg string equals greeting string\n",
- "\n",
+ "print(msg == greeting)\n",
"\n"
]
},
@@ -646,9 +963,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 51,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "message as expected\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run code\n",
"msg = \"Save the notebook\"\n",
@@ -661,9 +986,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 52,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "message as expected\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run code\n",
"msg = \"Save the notebook\"\n",
@@ -686,21 +1019,43 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 55,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "What is 8 + 13? : 21\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Correct! 8 + 13 is 21.\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get input for a variable, answer, and ask user 'What is 8 + 13? : '\n",
+ "answer = input(\"What is 8 + 13? : \")\n",
"# [ ] print messages for correct answer \"21\" or incorrect answer using if/else\n",
"# note: input returns a \"string\"\n",
- "\n",
+ "if answer == \"21\":\n",
+ " print(\"Correct! 8 + 13 is 21.\")\n",
+ "else:\n",
+ " print(\"Incorrect. The correct answer is 21.\")\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
" \n",
@@ -722,9 +1077,38 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 57,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Should save your notebook after edit?(T/F): True\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The correct answer was True\n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Can I learn python even if I am anxious and not sure of myself? Yes\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The correct answer was Yes you can!\n"
+ ]
+ }
+ ],
"source": [
"# [ ] Create the program, run tests\n",
"def tf_quiz(question=\"Should save your notebook after edit?(T/F): \",correct_ans=True):\n",
@@ -786,7 +1170,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"\n",
@@ -795,9 +1182,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 61,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter weather (sunny, rainy, snowy): snowy\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Wear a warm coat and hat\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review the code then run testing different inputs\n",
"# WHAT TO WEAR\n",
@@ -815,9 +1217,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 67,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter a guess for the secret number (1-3): 2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Guess is right\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review the code then run testing different inputs\n",
"# SECRET NUMBER GUESS\n",
@@ -854,12 +1271,36 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter shirt size (S, M, L): s\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Small = $6\n"
+ ]
+ }
+ ],
"source": [
"# [ ] code and test SHIRT SALE\n",
- "\n"
+ "size = input(\"Enter shirt size (S, M, L): \").upper()\n",
+ "\n",
+ "if size == \"S\":\n",
+ " print(\"Small = $6\")\n",
+ "elif size == \"M\":\n",
+ " print(\"Medium = $7\")\n",
+ "elif size == \"L\":\n",
+ " print(\"Large = $8\")\n",
+ "else:\n",
+ " print(\"Size\", size, \"is not available\")\n"
]
},
{
@@ -888,9 +1329,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "60170\n"
+ ]
+ }
+ ],
"source": [
"weight1 = '60' # a string\n",
"weight2 = 170 # an integer\n",
@@ -910,28 +1359,46 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "36\n"
+ ]
+ }
+ ],
"source": [
"str_num_1 = \"11\"\n",
"str_num_2 = \"15\"\n",
"int_num_3 = 10\n",
"# [ ] Add the 3 numbers as integers and print the result\n",
- "\n"
+ "total_int = int(str_num_1) + int(str_num_2) + int_num_3\n",
+ "print(total_int)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "111510\n"
+ ]
+ }
+ ],
"source": [
"str_num_1 = \"11\"\n",
"str_num_2 = \"15\"\n",
"int_num_3 = 10\n",
"# [ ] Add the 3 numbers as test strings and print the result\n",
- "\n"
+ "total_str = str_num_1 + str_num_2 + str(int_num_3)\n",
+ "print(total_str)\n"
]
},
{
@@ -948,12 +1415,25 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "75\n"
+ ]
+ }
+ ],
"source": [
"# [ ] code and test: adding using int casting\n",
- "\n"
+ "str_integer = \"25\"\n",
+ "int_number = 50\n",
+ "\n",
+ "number_total = int_number + int(str_integer)\n",
+ "\n",
+ "print(number_total)\n"
]
},
{
@@ -975,9 +1455,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "enter student age (integer): 18\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Next year student will be 19\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run code\n",
"student_age = input('enter student age (integer): ')\n",
@@ -987,9 +1482,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "enter student age (integer): 19\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "In a decade the student will be 29\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run code\n",
"# cast to int at input\n",
@@ -1003,7 +1513,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"\n",
@@ -1018,12 +1531,34 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter the first number: 1\n",
+ "Enter the second number: 2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1 + 2 = 3\n"
+ ]
+ }
+ ],
"source": [
"# [ ] code and test the adding calculator\n",
- "\n"
+ "\n",
+ "num_1 = input(\"Enter the first number: \")\n",
+ "num_2 = input(\"Enter the second number: \")\n",
+ "\n",
+ "total = int(num_1) + int(num_2)\n",
+ "\n",
+ "print(num_1, \"+\", num_2, \"=\", total)"
]
},
{
@@ -1047,7 +1582,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"# \n",
@@ -1062,7 +1600,10 @@
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"\n",
@@ -1071,9 +1612,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "3 + 5 = 8\n",
+ "3 + 5 - 9 = -1\n",
+ "48/9 = 5.333333333333333\n",
+ "5*5 = 25\n",
+ "(14 - 8)*(19/4) = 28.5\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run example\n",
"print(\"3 + 5 =\",3 + 5)\n",
@@ -1085,9 +1638,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "enter a non-decimal number you wish were bigger: 69\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Now you have 69000000\n"
+ ]
+ }
+ ],
"source": [
"# [ ] review and run example - 'million_maker'\n",
"def million_maker():\n",
@@ -1108,68 +1676,119 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 21,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "28\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print the result of subtracting 15 from 43\n",
- "\n"
+ "print(43 - 15)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 22,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "645\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print the result of multiplying 15 and 43\n",
- "\n"
+ "print(15 * 43)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 20,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "13.0\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print the result of dividing 156 by 12\n",
- "\n"
+ "print(156 / 12)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "42.0\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print the result of dividing 21 by 0.5\n",
- "\n"
+ "print(21 / 0.5)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "150\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print the result of adding 111 plus 84 and then subtracting 45\n",
- "\n"
+ "print(111 + 84 - 45)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "100\n"
+ ]
+ }
+ ],
"source": [
"# [ ] print the result of adding 21 and 4 and then multiplying that sum by 4\n",
- "\n"
+ "print((21 + 4) * 4)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"\n",
@@ -1187,19 +1806,45 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 24,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter the first whole number: 1\n",
+ "Enter the second whole number: 21\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1 * 21 = 21\n"
+ ]
+ }
+ ],
"source": [
"# [ ] create and test multiply() function\n",
+ "def multiply():\n",
+ " num_1 = input(\"Enter the first whole number: \")\n",
+ " num_2 = input(\"Enter the second whole number: \")\n",
+ " result = int(num_1) * int(num_2)\n",
+ " \n",
+ " return num_1 + \" * \" + num_2 + \" = \" + str(result)\n",
"\n",
+ "print(multiply())\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"\n",
@@ -1215,13 +1860,94 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 27,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Testing Division:\n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter first number: 21\n",
+ "Enter second number: 7\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "21 / 7 = 3.0\n",
+ "\n",
+ "Testing Default (Multiplication):\n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter first number: 31\n",
+ "Enter second number: 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "31 * 1 = 31\n",
+ "\n",
+ "Testing Invalid Operator:\n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter first number: 1\n",
+ "Enter second number: 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Invalid Operator\n"
+ ]
+ }
+ ],
"source": [
"# [ ] create improved multiply() function and test with /, no argument, and an invalid operator ($)\n",
"\n",
+ "def multiply(operator = \"*\"):\n",
+ "\n",
+ " num_1 = input(\"Enter first number: \")\n",
+ " num_2 = input(\"Enter second number: \")\n",
+ " \n",
+ "\n",
+ " if operator == \"*\":\n",
+ " result = int(num_1) * int(num_2)\n",
+ " return num_1 + \" * \" + num_2 + \" = \" + str(result)\n",
+ " \n",
+ " elif operator == \"/\":\n",
+ " result = int(num_1) / int(num_2)\n",
+ " return num_1 + \" / \" + num_2 + \" = \" + str(result)\n",
+ " \n",
+ " else:\n",
+ " return \"Invalid Operator\"\n",
+ "\n",
+ "print(\"Testing Division:\")\n",
+ "print(multiply(\"/\"))\n",
+ "\n",
+ "print(\"\\nTesting Default (Multiplication):\")\n",
+ "print(multiply())\n",
"\n",
+ "print(\"\\nTesting Invalid Operator:\")\n",
+ "print(multiply(\"$\"))\n",
" \n"
]
},
@@ -1236,28 +1962,36 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 29,
"metadata": {},
"outputs": [
{
- "ename": "SyntaxError",
- "evalue": "invalid syntax (, line 5)",
- "output_type": "error",
- "traceback": [
- "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m5\u001b[0m\n\u001b[0;31m elif student_name.startswith(\"G\")\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "enter name: matt\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Matt please wait for students with names staring with 'F' and 'G' to go first today.\n",
+ "Object `fail` not found.\n"
]
}
],
"source": [
"# Review, run, fix \n",
"student_name = input(\"enter name: \").capitalize()\n",
+ "\n",
"if student_name.startswith(\"F\"):\n",
- " print(student_name,\"Congratulations, names starting with 'F' get to go first today!\")\n",
- "elif student_name.startswith(\"G\")\n",
- " print(student_name,\"Congratulations, names starting with 'G' get to go second today!\")\n",
+ " print(student_name, \"Congratulations, names starting with 'F' get to go first today!\")\n",
+ "elif student_name.startswith(\"G\"): # <--- Added the missing colon here\n",
+ " print(student_name, \"Congratulations, names starting with 'G' get to go second today!\")\n",
"else:\n",
" print(student_name, \"please wait for students with names staring with 'F' and 'G' to go first today.\")\n",
- "\n"
+ "Why did it fail?\n"
]
},
{
@@ -1271,7 +2005,7 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -1285,9 +2019,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.8"
+ "version": "3.12.1"
}
},
"nbformat": 4,
- "nbformat_minor": 1
+ "nbformat_minor": 4
}
diff --git a/P1 Python Absolute Beginner/Module_3.1_Practice.ipynb b/P1 Python Absolute Beginner/Module_3.1_Practice.ipynb
index 8ee62fc4..686f079f 100644
--- a/P1 Python Absolute Beginner/Module_3.1_Practice.ipynb
+++ b/P1 Python Absolute Beginner/Module_3.1_Practice.ipynb
@@ -17,17 +17,23 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 1,
"metadata": {},
"outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Input your age (use only whole numbers): 18\n"
+ ]
+ },
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Input your age (use only whole numbers): 23\n",
"Age's first type is: \n",
"Age's second type is: \n",
- "In ten years you will be 33.\n"
+ "In ten years you will be 28.\n"
]
}
],
@@ -51,10 +57,8 @@
},
{
"cell_type": "code",
- "execution_count": 4,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 2,
+ "metadata": {},
"outputs": [
{
"name": "stdout",
@@ -90,19 +94,50 @@
},
{
"cell_type": "code",
- "execution_count": 9,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 3,
+ "metadata": {},
"outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Guess the letter (provide one letter): o\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Low\n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Guess the letter (provide one letter): O\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Low\n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Guess the letter (provide one letter): W\n"
+ ]
+ },
{
"name": "stdout",
"output_type": "stream",
"text": [
"Low\n",
- "Invalid - not alphabetical\n",
- "Correct\n",
- "On the third try! Sortta slow.\n"
+ "You lose.\n"
]
}
],
@@ -158,7 +193,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"outputs": [],
"source": [
@@ -182,14 +220,47 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter guess 1: M\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Correct\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# [ ] create letter_guess() function, call the function to test\n",
+ "def letter_guess(answer):\n",
+ " if check_guess(answer, input(\"Enter guess 1: \")):\n",
+ " return True\n",
+ " if check_guess(answer, input(\"Enter guess 2: \")):\n",
+ " return True\n",
+ " if check_guess(answer, input(\"Enter guess 3: \")):\n",
+ " return True\n",
+ " \n",
+ " return False\n",
"\n",
+ "letter_guess(\"M\")\n",
"\n"
]
},
@@ -210,14 +281,41 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
+ "execution_count": 15,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Tell me about your pet: dog\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Ah, a dog! They are so loyal.\n",
+ "It sounds like you have a wonderful animal companion.\n",
+ "Thank you for sharing your story!\n"
+ ]
+ }
+ ],
"source": [
"# [ ] complete pet conversation\n",
- "\n"
+ "about_pet = input(\"Tell me about your pet: \").lower()\n",
+ "\n",
+ "if \"dog\" in about_pet:\n",
+ " print(\"Ah, a dog! They are so loyal.\")\n",
+ " \n",
+ "if \"cat\" in about_pet:\n",
+ " print(\"A cat! I bet they enjoy a good nap.\")\n",
+ "\n",
+ "# Check if at least one animal (dog or cat) was mentioned\n",
+ "if \"dog\" in about_pet or \"cat\" in about_pet:\n",
+ " print(\"It sounds like you have a wonderful animal companion.\")\n",
+ "\n",
+ "print(\"Thank you for sharing your story!\")\n"
]
},
{
@@ -262,25 +360,58 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"# [ ] complete rainbow colors\n",
- "\n",
- "\n"
+ "def rainbow_color(letter):\n",
+ " letter = letter.upper()\n",
+ " \n",
+ " if letter == \"R\":\n",
+ " return \"Red\"\n",
+ " elif letter == \"O\":\n",
+ " return \"Orange\"\n",
+ " elif letter == \"Y\": \n",
+ " return \"Yellow\"\n",
+ " elif letter == \"G\":\n",
+ " return \"Green\"\n",
+ " elif letter == \"B\":\n",
+ " return \"Blue\"\n",
+ " elif letter == \"I\":\n",
+ " return \"Indigo\"\n",
+ " elif letter == \"V\":\n",
+ " return \"Violet\"\n",
+ " else:\n",
+ " return \"no match\"\n"
]
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 29,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter the first letter of a rainbow color (ROYGBIV): R\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Red\n"
+ ]
+ }
+ ],
"source": [
"# [ ] make the code above into a function rainbow_color() that has a string parameter, \n",
"# get input and call the function and return the matching color as a string or \"no match\" message.\n",
"# Call the function and print the return string.\n",
- "\n"
+ "fav_color = input(\"Enter the first letter of a rainbow color (ROYGBIV): \")\n",
+ "print(rainbow_color(fav_color))\n"
]
},
{
@@ -296,12 +427,36 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 33,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter your age: 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "25 years old, 20 years difference from now\n"
+ ]
+ }
+ ],
"source": [
"# [ ] complete age_20()\n",
- "\n"
+ "def age_20(age):\n",
+ " if age >= 20:\n",
+ " return age - 20\n",
+ " else:\n",
+ " return age + 20\n",
+ "\n",
+ "user_age = int(input(\"Enter your age: \"))\n",
+ "result = age_20(user_age)\n",
+ "\n",
+ "print(str(result) + \" years old, 20 years difference from now\")\n"
]
},
{
@@ -316,72 +471,198 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 36,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter a letter or a number: 20\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "0\n"
+ ]
+ }
+ ],
"source": [
"# [ ] create rainbow_or_age()\n",
- "\n"
+ "def rainbow_or_age(argument):\n",
+ " if argument.isdigit():\n",
+ " return age_20(int(argument))\n",
+ " elif argument.isalpha():\n",
+ " return rainbow_color(argument)\n",
+ " else:\n",
+ " return False\n",
+ "\n",
+ "test_input = input(\"Enter a letter or a number: \")\n",
+ "print(rainbow_or_age(test_input))\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 39,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter first number: 1\n",
+ "Enter second number: 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "2\n"
+ ]
+ }
+ ],
"source": [
"# [ ] add 2 numbers from input using a cast to integer and display the answer \n",
- "\n"
+ "num1 = int(input(\"Enter first number: \"))\n",
+ "num2 = int(input(\"Enter second number: \"))\n",
+ "print(num1 + num2)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 38,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter a number to multiply: 2\n",
+ "Enter another: 2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the answer is 4\n"
+ ]
+ }
+ ],
"source": [
"# [ ] Multiply 2 numbers from input using cast and save the answer as part of a string \"the answer is...\"\n",
"# display the string using print\n",
+ "num3 = int(input(\"Enter a number to multiply: \"))\n",
+ "num4 = int(input(\"Enter another: \"))\n",
+ "answer_str = \"the answer is \" + str(num3 * num4)\n",
+ "print(answer_str)\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 40,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter number 1 for average: 1\n",
+ "Enter number 2 for average: 2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1.5\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get input of 2 numbers and display the average: (num1 + num2) divided by 2\n",
- "\n"
+ "n1 = float(input(\"Enter number 1 for average: \"))\n",
+ "n2 = float(input(\"Enter number 2 for average: \"))\n",
+ "print((n1 + n2) / 2)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 41,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter first value: 1\n",
+ "Enter second value: 2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1.0\n"
+ ]
+ }
+ ],
"source": [
"# [ ] get input of 2 numbers and subtract the largest from the smallest (use an if statement to see which is larger)\n",
"# show the answer\n",
- "\n"
+ "val1 = float(input(\"Enter first value: \"))\n",
+ "val2 = float(input(\"Enter second value: \"))\n",
+ "if val1 > val2:\n",
+ " print(val1 - val2)\n",
+ "else:\n",
+ " print(val2 - val1)\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 42,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Enter a large number: 200\n",
+ "Enter a small number: 100\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "2\n"
+ ]
+ }
+ ],
"source": [
"# [ ] Divide a larger number by a smaller number and print the integer part of the result\n",
"# don't divide by zero! if a zero is input make the result zero\n",
"# [ ] cast the answer to an integer to cut off the decimals and print the result\n",
- "\n"
+ "big_num = float(input(\"Enter a large number: \"))\n",
+ "small_num = float(input(\"Enter a small number: \"))\n",
+ "if small_num == 0:\n",
+ " print(0)\n",
+ "else:\n",
+ " result = int(big_num / small_num)\n",
+ " print(result)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"[Terms of use](http://go.microsoft.com/fwlink/?LinkID=206977) [Privacy & cookies](https://go.microsoft.com/fwlink/?LinkId=521839) © 2017 Microsoft"
@@ -391,7 +672,7 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -405,9 +686,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.13.1"
+ "version": "3.12.1"
}
},
"nbformat": 4,
- "nbformat_minor": 1
+ "nbformat_minor": 4
}
diff --git a/P1 Python Absolute Beginner/Module_3.2_Required_Code.ipynb b/P1 Python Absolute Beginner/Module_3.2_Required_Code.ipynb
index be372666..1f7f22fe 100644
--- a/P1 Python Absolute Beginner/Module_3.2_Required_Code.ipynb
+++ b/P1 Python Absolute Beginner/Module_3.2_Required_Code.ipynb
@@ -1,89 +1,122 @@
{
- "cells": [
- {
- "attachments": {},
- "cell_type": "markdown",
- "metadata": {
- "collapsed": true
- },
- "source": [
- "# P1M3: Module 3 Required Coding Activity \n",
- "Introduction to Python Unit 1 \n",
- "\n",
- "This is an activity based on code similar to Tutorial and Practice code you should have completed already.\n",
- "\n",
- ">This program requires the use of **`if, elif, else`**, and casting between strings and numbers. The program should use the various code syntax covered in module 3. \n",
- "> \n",
- ">The program must result in print output using numeric input similar to that shown in the sample below.\n",
- ">You must include your full name in the input prompt (meaning it needs to be spelled out in the code file). See sample below for more detail.\n",
- "\n",
- "## Program: Cheese Order Function \n",
- "- define function with max, min, price, and order_amount parameters\n",
- "- set default values for maximum and minimum order parameters \n",
- "- set default value for price parameter\n",
- "- cast order_amount and other arguments to numbers \n",
- "- check order_amount and give message checking against \n",
- " - over maximum\n",
- " - under minimum\n",
- "- else within maximum and minimum give message with calculated price \n",
- "- call your function using order weight input from user\n",
- "\n",
- "\n",
- "Sample input and output:\n",
- "```\n",
- "[YOUR FULL NAME GOES HERE], enter cheese order weight (numeric value): 113\n",
- "113.0 is more than currently available stock\n",
- "```\n",
- "\n",
- "```\n",
- "[YOUR FULL NAME GOES HERE], enter cheese order weight (numeric value): .15\n",
- "0.15 is below minimum order amount\n",
- "``` \n",
- "\n",
- "```\n",
- "[YOUR FULL NAME GOES HERE], enter cheese order weight (numeric value): 2\n",
- "2.0 costs $15.98\n",
- "``` "
- ]
- },
+ "cells": [
+ {
+ "attachments": {},
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
+ },
+ "source": [
+ "# P1M3: Module 3 Required Coding Activity \n",
+ "Introduction to Python Unit 1 \n",
+ "\n",
+ "This is an activity based on code similar to Tutorial and Practice code you should have completed already.\n",
+ "\n",
+ ">This program requires the use of **`if, elif, else`**, and casting between strings and numbers. The program should use the various code syntax covered in module 3. \n",
+ "> \n",
+ ">The program must result in print output using numeric input similar to that shown in the sample below.\n",
+ ">You must include your full name in the input prompt (meaning it needs to be spelled out in the code file). See sample below for more detail.\n",
+ "\n",
+ "## Program: Cheese Order Function \n",
+ "- define function with max, min, price, and order_amount parameters\n",
+ "- set default values for maximum and minimum order parameters \n",
+ "- set default value for price parameter\n",
+ "- cast order_amount and other arguments to numbers \n",
+ "- check order_amount and give message checking against \n",
+ " - over maximum\n",
+ " - under minimum\n",
+ "- else within maximum and minimum give message with calculated price \n",
+ "- call your function using order weight input from user\n",
+ "\n",
+ "\n",
+ "Sample input and output:\n",
+ "```\n",
+ "[YOUR FULL NAME GOES HERE], enter cheese order weight (numeric value): 113\n",
+ "113.0 is more than currently available stock\n",
+ "```\n",
+ "\n",
+ "```\n",
+ "[YOUR FULL NAME GOES HERE], enter cheese order weight (numeric value): .15\n",
+ "0.15 is below minimum order amount\n",
+ "``` \n",
+ "\n",
+ "```\n",
+ "[YOUR FULL NAME GOES HERE], enter cheese order weight (numeric value): 2\n",
+ "2.0 costs $15.98\n",
+ "``` "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [
{
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "trusted": false
- },
- "outputs": [],
- "source": [
- "# [ ] create fucntion, call and test \n"
- ]
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Matthew Williams, enter cheese order weight (numeric value): 2\n"
+ ]
},
{
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Submit this by creating a python file (.py) and submitting it in D2L. Be sure to test that it works."
- ]
- }
- ],
- "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.5.4"
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "2.0 costs $15.98\n"
+ ]
}
+ ],
+ "source": [
+ "# [ ] create fucntion, call and test \n",
+ "def cheese_program(order_amount, max_amount=100.0, min_amount=0.5, price=7.99):\n",
+ " order_amount = float(order_amount)\n",
+ " max_amount = float(max_amount)\n",
+ " min_amount = float(min_amount)\n",
+ " if order_amount > max_amount:\n",
+ " print(f\"{order_amount} is more than currently available stock\")\n",
+ " elif order_amount < min_amount:\n",
+ " print(f\"{order_amount} is below minimum order amount\")\n",
+ " else:\n",
+ " # Calculate total cost\n",
+ " total_cost = order_amount * price\n",
+ " print(f\"{order_amount} costs ${total_cost:.2f}\")\n",
+ "\n",
+ "name = \"Matthew Williams\"\n",
+ "user_weight = input(f\"{name}, enter cheese order weight (numeric value): \")\n",
+ "\n",
+ "cheese_program(user_weight)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Submit this by creating a python file (.py) and submitting it in D2L. Be sure to test that it works."
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
},
- "nbformat": 4,
- "nbformat_minor": 1
+ "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.12.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
}
diff --git a/P1 Python Absolute Beginner/p1m1matthewwilliams.ipynb b/P1 Python Absolute Beginner/p1m1matthewwilliams.ipynb
new file mode 100644
index 00000000..2879a74a
--- /dev/null
+++ b/P1 Python Absolute Beginner/p1m1matthewwilliams.ipynb
@@ -0,0 +1,67 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "8148dccc-93f6-4c65-933a-ecc33e14cc87",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Names of people met in past 24 hours: Josh, sEth, maTt, johN\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "josh, seth, matt, john\n",
+ "John met? True\n",
+ "Matt met? True\n",
+ "Josh met? True\n",
+ "Seth met? True\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Create name check code\n",
+ "input_test = input(\"Names of people met in past 24 hours: \").lower()\n",
+ "# [ ] get input for input_test variable\n",
+ "print(input_test)\n",
+ "# [ ] print \"True\" message if \"John\" is in the input or False message if not\n",
+ "print(\"John met?\", \"john\" in input_test)\n",
+ "\n",
+ "# [ ] print True message if your name is in the input or False if not\n",
+ "print(\"Matt met?\", \"matt\" in input_test)\n",
+ "\n",
+ "# [ ] Challenge: Check if another person's name is in the input - print message\n",
+ "print(\"Josh met?\", \"josh\" in input_test)\n",
+ "print(\"Seth met?\", \"seth\" in input_test)\n",
+ "# [ ] Challenge: Check if a fourth person's name is in the input - print message\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "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.12.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/P1 Python Absolute Beginner/p1m2matthewwilliams.py b/P1 Python Absolute Beginner/p1m2matthewwilliams.py
new file mode 100644
index 00000000..17d699ea
--- /dev/null
+++ b/P1 Python Absolute Beginner/p1m2matthewwilliams.py
@@ -0,0 +1,8 @@
+# [ ] create, call and test fishstore() function
+def fishstore(fish, price):
+ # Returns a string in sentence form
+ return "Fish Type: " + fish + " costs $" + price
+fish_entry = input("Enter the fish type: ")
+price_entry = input("Enter the price: ")
+report = fishstore(fish_entry, price_entry)
+print("Report for Matthew Williams. " + report)
diff --git a/P1 Python Absolute Beginner/p1m3matthewwilliams.py b/P1 Python Absolute Beginner/p1m3matthewwilliams.py
new file mode 100644
index 00000000..00c916a9
--- /dev/null
+++ b/P1 Python Absolute Beginner/p1m3matthewwilliams.py
@@ -0,0 +1,17 @@
+# [ ] create fucntion, call and test
+def cheese_program(order_amount, max_amount=100.0, min_amount=0.5, price=7.99):
+ order_amount = float(order_amount)
+ max_amount = float(max_amount)
+ min_amount = float(min_amount)
+ if order_amount > max_amount:
+ print(f"{order_amount} is more than currently available stock")
+ elif order_amount < min_amount:
+ print(f"{order_amount} is below minimum order amount")
+ else:
+ total_cost = order_amount * price
+ print(f"{order_amount} costs ${total_cost:.2f}")
+
+name = "Matthew Williams"
+user_weight = input(f"{name}, enter cheese order weight (numeric value): ")
+
+cheese_program(user_weight)
diff --git a/P1 Python Absolute Beginner/pythonteachingcode.code-workspace b/P1 Python Absolute Beginner/pythonteachingcode.code-workspace
new file mode 100644
index 00000000..2a0ed79b
--- /dev/null
+++ b/P1 Python Absolute Beginner/pythonteachingcode.code-workspace
@@ -0,0 +1,7 @@
+{
+ "folders": [
+ {
+ "path": ".."
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Untitled.ipynb b/Untitled.ipynb
new file mode 100644
index 00000000..363fcab7
--- /dev/null
+++ b/Untitled.ipynb
@@ -0,0 +1,6 @@
+{
+ "cells": [],
+ "metadata": {},
+ "nbformat": 4,
+ "nbformat_minor": 5
+}