From 8bebd188d5d4dde5e6e1d95c0b5dea11b8b4a148 Mon Sep 17 00:00:00 2001 From: Serandib <31516819+DeepXU@users.noreply.github.com> Date: Mon, 28 Feb 2022 15:50:01 -0500 Subject: [PATCH] Add files via upload --- Python_Mod_01.ipynb | 421 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 421 insertions(+) create mode 100644 Python_Mod_01.ipynb diff --git a/Python_Mod_01.ipynb b/Python_Mod_01.ipynb new file mode 100644 index 0000000..6af002d --- /dev/null +++ b/Python_Mod_01.ipynb @@ -0,0 +1,421 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "13cd8105-68bf-4b52-9977-0d3654bd960d", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"Hello, World!\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6524b125-5d4f-4b48-907a-a38059d5c682", + "metadata": {}, + "outputs": [], + "source": [ + "prin(\"Hello, world! My name is Type your name here\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "26dfd455-80b6-45c6-af8e-f4533eb3d8f6", + "metadata": {}, + "outputs": [], + "source": [ + "print()" + ] + }, + { + "cell_type": "raw", + "id": "065e65e5-345d-4a4c-b16c-de3f4af86e2d", + "metadata": {}, + "source": [ + "The print() function - instructions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "637daab9-e216-492f-b2f5-4645b661563b", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"The itsy bitsy spider climbed up the waterspout.\")\n", + "print(\"Down came the rain and washed the spider out.\") \n" + ] + }, + { + "cell_type": "markdown", + "id": "7a2fce42-fd4c-4745-bb2b-5fdd838bcf5c", + "metadata": {}, + "source": [ + "The print() function - instructions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bab7f145-0f4f-4fc0-8e04-0ba4c60873b0", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"The itsy bitsy spider climbed up the waterspout.\")\n", + "print()\n", + "print(\"Down came the rain and washed the spider out.\")" + ] + }, + { + "cell_type": "raw", + "id": "3faef436-8afe-4ceb-a9fc-1eba52d15a8d", + "metadata": {}, + "source": [ + "The print() function - the escape and newline characters" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a8479fdf-a9ed-4e33-8919-68bb31115cde", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"The itsy bitsy spider\\nclimbed up the waterspout.\")\n", + "print()\n", + "print(\"Down came the rain\\nand washed the spider out.\")" + ] + }, + { + "cell_type": "raw", + "id": "c93fa8c8-ccf0-40b1-9716-ec59b968967b", + "metadata": {}, + "source": [ + "The print() function - using multiple arguments" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c742d903-9cbf-40d9-94a4-72c829cdfc0e", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"The itsy bitsy spider\" , \"climbed up\" , \"the waterspout.\")" + ] + }, + { + "cell_type": "raw", + "id": "60432741-67e3-496a-91fe-17de1eeaebfa", + "metadata": {}, + "source": [ + "The print() function - the positional way of passing the arguments" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0af17834-fbed-497a-b9c7-20e906bf5851", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"My name is\", \"Python.\")\n", + "print(\"Monty Python.\")\n" + ] + }, + { + "cell_type": "raw", + "id": "cdca2d4c-9c9f-490f-8f98-fb83bdf72ad8", + "metadata": {}, + "source": [ + "The print() function - the keyword arguments" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8bb0d293-35d7-4321-b258-14a6dc1e6fc4", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"My name is\", \"Python.\", end=\" \")\n", + "print(\"Monty Python.\")" + ] + }, + { + "cell_type": "raw", + "id": "0bfb7d3a-55cb-4b2c-9b12-0cef9728cfa4", + "metadata": {}, + "source": [ + "The print() function - the keyword arguments" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2500b337-e7be-4631-82d5-b10855e02f43", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"My name is \", end=\"\")\n", + "print(\"Monty Python.\")\n" + ] + }, + { + "cell_type": "raw", + "id": "e635c7fc-7ba3-4af6-a9c5-fa9a30163243", + "metadata": {}, + "source": [ + "The print() function - the keyword arguments" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8ed0836b-8268-41fc-ae9a-0f2090011c7e", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"My\", \"name\", \"is\", \"Monty\", \"Python.\", sep=\"-\")" + ] + }, + { + "cell_type": "raw", + "id": "915cea15-6de1-4c3d-9ea3-c87b3b618f4f", + "metadata": {}, + "source": [ + "The print() function - the keyword arguments" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7a9efccc-e207-48cb-8614-b20790a0d327", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"My\", \"name\", \"is\", sep=\"_\", end=\"*\")\n", + "print(\"Monty\", \"Python.\", sep=\"*\", end=\"*\\n\")" + ] + }, + { + "cell_type": "raw", + "id": "132cdd99-f267-431f-8dc8-786b04d52b4f", + "metadata": {}, + "source": [ + "In class lab 2\n", + "Estimated time\n", + "\n", + "5-10 minutes\n", + "Level of difficulty\n", + "\n", + "Very Easy\n", + "Objectives\n", + "\n", + " becoming familiar with the print() function and its formatting capabilities;\n", + " experimenting with Python code.\n", + "\n", + "Scenario\n", + "\n", + "Modify the first line of code in the editor, using the sep and end keywords, to match the expected output. Use the two print() functions in the editor.\n", + "\n", + "Don't change anything in the second print() invocation.\n", + "Expected output\n", + "Programming***Essentials***in...Python\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2e51ba20-687a-4785-bf72-a0fec393cd4b", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"Programming\",\"Essentials\",\"in\")\n", + "print(\"Python\")\n" + ] + }, + { + "cell_type": "raw", + "id": "98a5b961-c6ba-4f5a-8dd9-a13272409107", + "metadata": {}, + "source": [ + "In class lab 3\n", + "Estimated time\n", + "\n", + "5-15 minutes\n", + "Level of difficulty\n", + "\n", + "Easy\n", + "Objectives\n", + "\n", + " experimenting with existing Python code;\n", + " discovering and fixing basic syntax errors;\n", + " becoming familiar with the print() function and its formatting capabilities.\n", + "\n", + "Scenario\n", + "\n", + "We strongly encourage you to play with the code written for you, and make some (maybe even destructive) amendments. Feel free to modify any part of the code, but there is one condition - learn from your mistakes and draw your own conclusions.\n", + "\n", + "Try to:\n", + "\n", + " 1. minimize the number of print() function invocations by inserting the \\n sequence into the strings\n", + " 2. make the arrow twice as large (but keep the proportions)\n", + " 3. duplicate the arrow, placing both arrows side by side; note: a string may be multiplied by using the following trick: \"string\" * 2 will produce \"stringstring\" (we'll tell you more about it soon)\n", + " 4. remove any of the quotes, and look carefully at Python's response; pay attention to where Python sees an error - is this the place where the error really exists?\n", + " 5. do the same with some of the parentheses;\n", + " 6. change any of the print words into something else, differing only in case (e.g., Print) - what happens now?\n", + " 7. replace some of the quotes with apostrophes; watch what happens carefully.\n", + " \n", + " Sample output\n", + " original version:\n", + "\n", + " *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + "*** ***\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " *****\n", + "\n", + "with fewer 'print()' invocations:\n", + "\n", + " *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + "*** ***\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " *****\n", + "\n", + "higher:\n", + "\n", + " *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + "****** ******\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " * *\n", + "\n", + " *******\n", + "\n", + "doubled:\n", + "\n", + " * * \n", + "\n", + " * * * * \n", + "\n", + " * * * * \n", + "\n", + " * * * * \n", + "\n", + " * * * * \n", + "\n", + " * * * * \n", + "\n", + " * * * * \n", + "\n", + " * * * * \n", + "\n", + "****** ************ ******\n", + "\n", + " * * * * \n", + "\n", + " * * * * \n", + "\n", + " * * * * \n", + "\n", + " * * * * \n", + "\n", + " * * * * \n", + "\n", + " * * * * \n", + "\n", + " ******* ******* \n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7a29926a-afb0-400f-97c5-62e6175be63c", + "metadata": {}, + "outputs": [], + "source": [ + "print(\" *\")\n", + "print(\" * *\")\n", + "print(\" * *\")\n", + "print(\" * *\")\n", + "print(\"*** ***\")\n", + "print(\" * *\")\n", + "print(\" * *\")\n", + "print(\" *****\")" + ] + } + ], + "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.8.10" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}