From 1785494e5480157b5291f767fb494b9d55c036c4 Mon Sep 17 00:00:00 2001 From: Colin Sepkovic Date: Sat, 5 Oct 2024 19:11:48 +0000 Subject: [PATCH 1/6] Turtle setup method edits --- lessons/00_Turtles/02_Meet_Tina.py | 2 +- lessons/00_Turtles/04a_Turtle_Tricks.py | 2 +- lessons/00_Turtles/04b_Turtle_Tricks.py | 2 +- lessons/00_Turtles/04c_Turtle_Tricks.py | 2 +- lessons/00_Turtles/05a_Loops.ipynb | 2 +- lessons/00_Turtles/05b_Loop_with_Turtle.py | 2 +- lessons/00_Turtles/06_Variables_and_Functions.ipynb | 2 +- lessons/00_Turtles/06a_Variables_and_Functions.ipynb | 2 +- lessons/00_Turtles/07_Efficient_Turtle.py | 2 +- lessons/00_Turtles/09_LeagueBot.py | 2 +- lessons/00_Turtles/12_Color_Lines.py | 2 +- lessons/00_Turtles/13_Flaming_Ninja_Star.py | 2 +- lessons/02_Loops/03b_Crazy_Tina.py | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lessons/00_Turtles/02_Meet_Tina.py b/lessons/00_Turtles/02_Meet_Tina.py index 273c17ed..a44efa67 100644 --- a/lessons/00_Turtles/02_Meet_Tina.py +++ b/lessons/00_Turtles/02_Meet_Tina.py @@ -11,7 +11,7 @@ """ import turtle # Tell Python we want to work with the turtle -turtle.setup(width=600, height=600) # Set the size of the window +turtle.setup(width=600, height=600, startx=0, starty=0) # Set the size of the window tina = turtle.Turtle() # Create a turtle named tina diff --git a/lessons/00_Turtles/04a_Turtle_Tricks.py b/lessons/00_Turtles/04a_Turtle_Tricks.py index 0b03a4a1..22b7de84 100644 --- a/lessons/00_Turtles/04a_Turtle_Tricks.py +++ b/lessons/00_Turtles/04a_Turtle_Tricks.py @@ -10,7 +10,7 @@ # These lines are needed in most turtle programs import turtle # Tell Python we want to work with the turtle -turtle.setup (width=600, height=600) # Set the size of the window +turtle.setup (width=600, height=600, startx=0, starty=0) # Set the size of the window tina = turtle.Turtle() # Create a turtle named tina diff --git a/lessons/00_Turtles/04b_Turtle_Tricks.py b/lessons/00_Turtles/04b_Turtle_Tricks.py index d8809f47..d8f25b93 100644 --- a/lessons/00_Turtles/04b_Turtle_Tricks.py +++ b/lessons/00_Turtles/04b_Turtle_Tricks.py @@ -10,7 +10,7 @@ # These lines are needed in most turtle programs import turtle # Tell Python we want to work with the turtle -turtle.setup (width=600, height=600) # Set the size of the window +turtle.setup (width=600, height=600, startx=0, starty=0) # Set the size of the window tina = turtle.Turtle() # Create a turtle named tina # Use tina.forward() and tina.left() to draw a pentagon diff --git a/lessons/00_Turtles/04c_Turtle_Tricks.py b/lessons/00_Turtles/04c_Turtle_Tricks.py index 2cf9ab33..e1290aae 100644 --- a/lessons/00_Turtles/04c_Turtle_Tricks.py +++ b/lessons/00_Turtles/04c_Turtle_Tricks.py @@ -12,7 +12,7 @@ # These lines are needed in most turtle programs import turtle # Tell Python we want to work with the turtle -turtle.setup (width=600, height=600) # Set the size of the window +turtle.setup (width=600, height=600, startx=0, starty=0) # Set the size of the window tina = turtle.Turtle() # Create a turtle named tina # Use tina.circle() to draw a circle, and tina.goto() to move tina to a new location diff --git a/lessons/00_Turtles/05a_Loops.ipynb b/lessons/00_Turtles/05a_Loops.ipynb index 66ed0851..4342848a 100644 --- a/lessons/00_Turtles/05a_Loops.ipynb +++ b/lessons/00_Turtles/05a_Loops.ipynb @@ -11,7 +11,7 @@ "\n", "```python \n", "import turtle # Tell Python we want to work with the turtle\n", - "turtle.setup (width=600, height=600) # Set the size of the window\n", + "turtle.setup (width=600, height=600, startx=0, starty=0) # Set the size of the window\n", "\n", "tina = turtle.Turtle() # Create a turtle named tina\n", "\n", diff --git a/lessons/00_Turtles/05b_Loop_with_Turtle.py b/lessons/00_Turtles/05b_Loop_with_Turtle.py index 5aed03b9..be8fe827 100644 --- a/lessons/00_Turtles/05b_Loop_with_Turtle.py +++ b/lessons/00_Turtles/05b_Loop_with_Turtle.py @@ -9,7 +9,7 @@ import turtle # Tell Python we want to work with the turtle -turtle.setup (width=600, height=600) # Set the size of the window +turtle.setup (width=600, height=600, startx=0, starty=0) # Set the size of the window tina = turtle.Turtle() # Create a turtle named tina diff --git a/lessons/00_Turtles/06_Variables_and_Functions.ipynb b/lessons/00_Turtles/06_Variables_and_Functions.ipynb index 7c06f670..9aaa1cc6 100644 --- a/lessons/00_Turtles/06_Variables_and_Functions.ipynb +++ b/lessons/00_Turtles/06_Variables_and_Functions.ipynb @@ -23,7 +23,7 @@ "```python \n", "\n", "import turtle # Tell Python we want to work with the turtle\n", - "turtle.setup(width=600, height=600) # Set the size of the window\n", + "turtle.setup(width=600, height=600, startx=0, starty=0) # Set the size of the window\n", "\n", "tina = turtle.Turtle() # Create a turtle named tina\n", "\n", diff --git a/lessons/00_Turtles/06a_Variables_and_Functions.ipynb b/lessons/00_Turtles/06a_Variables_and_Functions.ipynb index 27d37bbf..a7e5ec89 100644 --- a/lessons/00_Turtles/06a_Variables_and_Functions.ipynb +++ b/lessons/00_Turtles/06a_Variables_and_Functions.ipynb @@ -12,7 +12,7 @@ "```python \n", "\n", "import turtle # Tell Python we want to work with the turtle\n", - "turtle.setup(width=600, height=600) # Set the size of the window\n", + "turtle.setup(width=600, height=600, startx=0, starty=0) # Set the size of the window\n", "\n", "tina = turtle.Turtle() # Create a turtle named tina\n", "\n", diff --git a/lessons/00_Turtles/07_Efficient_Turtle.py b/lessons/00_Turtles/07_Efficient_Turtle.py index 46865d59..0cc7db7c 100644 --- a/lessons/00_Turtles/07_Efficient_Turtle.py +++ b/lessons/00_Turtles/07_Efficient_Turtle.py @@ -8,7 +8,7 @@ import turtle # Tell Python we want to work with the turtle -turtle.setup (width=600, height=600) # Set the size of the window +turtle.setup (width=600, height=600, startx=0, starty=0) # Set the size of the window tina = turtle.Turtle() # Create a turtle named tina diff --git a/lessons/00_Turtles/09_LeagueBot.py b/lessons/00_Turtles/09_LeagueBot.py index 3aa88030..00034125 100644 --- a/lessons/00_Turtles/09_LeagueBot.py +++ b/lessons/00_Turtles/09_LeagueBot.py @@ -12,7 +12,7 @@ import turtle as turtle screen = turtle.Screen() -screen.setup(width=600, height=600) +screen.setup(width=600, height=600, startx=0, starty=0) screen.bgcolor('white') t = turtle.Turtle() diff --git a/lessons/00_Turtles/12_Color_Lines.py b/lessons/00_Turtles/12_Color_Lines.py index 6ed3102e..0c4010b4 100644 --- a/lessons/00_Turtles/12_Color_Lines.py +++ b/lessons/00_Turtles/12_Color_Lines.py @@ -6,7 +6,7 @@ """ import turtle # Tell Python we want to work with the turtle -turtle.setup (width=600, height=600) # Set the size of the window +turtle.setup (width=600, height=600, startx=0, starty=0) # Set the size of the window tina = turtle.Turtle() # Create a turtle named tina diff --git a/lessons/00_Turtles/13_Flaming_Ninja_Star.py b/lessons/00_Turtles/13_Flaming_Ninja_Star.py index b8c8464b..83f94266 100644 --- a/lessons/00_Turtles/13_Flaming_Ninja_Star.py +++ b/lessons/00_Turtles/13_Flaming_Ninja_Star.py @@ -19,7 +19,7 @@ def getRandomColor(): def getNextColor(i): return colors[i % len(colors)] -turtle.setup (width=600, height=600) +turtle.setup (width=600, height=600, startx=0, starty=0) window = turtle.Screen() baseSize = 200 # the size of the black part of the star diff --git a/lessons/02_Loops/03b_Crazy_Tina.py b/lessons/02_Loops/03b_Crazy_Tina.py index bb2582f5..03d24901 100644 --- a/lessons/02_Loops/03b_Crazy_Tina.py +++ b/lessons/02_Loops/03b_Crazy_Tina.py @@ -14,7 +14,7 @@ import turtle # Tell Python we want to work with the turtle -turtle.setup (width=600, height=600) # Set the size of the window +turtle.setup (width=600, height=600, startx=0, starty=0) # Set the size of the window tina = turtle.Turtle() # Create a turtle named tina From b74ddeeb48b0da815d666a81bef3d97b6c7b2c4d Mon Sep 17 00:00:00 2001 From: Eric Busboom Date: Wed, 28 Aug 2024 17:16:29 -0700 Subject: [PATCH 2/6] . --- lessons/00_Turtles/01_Get_Started.ipynb | 31 +++++++++++++++++-- .../00_Turtles/08a_More_Turtle_Programs.ipynb | 2 ++ lessons/00_Turtles/16_Turtle_Spiral.py | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lessons/00_Turtles/01_Get_Started.ipynb b/lessons/00_Turtles/01_Get_Started.ipynb index aa7e7a3d..baca5811 100644 --- a/lessons/00_Turtles/01_Get_Started.ipynb +++ b/lessons/00_Turtles/01_Get_Started.ipynb @@ -151,14 +151,41 @@ "\n", "### Hit the F5 Key\n", "\n", - "You can also run the program by hitting the F5 key. On a Mac, you will have to hold down the fn key and then hit F5. \n", + "You can also run the program by hitting the F5 key. On a Mac, you will have to\n", + "hold down the fn key and then hit F5. THis is a bit different than using the run\n", + "button, because F5 will open the debugger. \n", + "\n", + "The first time you hit F5, look at the top of the IDE window. YOu shoudl see a\n", + "selection window that reads \"Select Debugger\". Select the first option, \"Python\n", + "Debugger\". Then, on the next window, select \"Python File. Debug currently active\n", + "Python file\". After that, you will see the debug bar: \n", + "\n", + "
\n", + "\n", + "We will learn all of the features for the debugger later, but for now you just\n", + "need to know that you press the red square to exit your program, and the gree\n", + "circle to re-run it. \n", "\n", "\n", "
\n", - " You can't run a program again until you end the currently running program. If you see a turtle window open, then you should either click on the window to close it ( if the program ends with `turtle.exitonclick()` or click on the X in the upper right of the turtle window. )\n", + "\n", + "You can't run a program again until you end the currently running program. If\n", + "you see a turtle window open, then you should either click on the window to\n", + "close it ( if the program ends with `turtle.exitonclick()` or click on the X in\n", + "the upper right of the turtle window. )\n", + "\n", + "Or, if you are using the debugger, click the red square in the debugger bar. \n", + "\n", "
" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, diff --git a/lessons/00_Turtles/08a_More_Turtle_Programs.ipynb b/lessons/00_Turtles/08a_More_Turtle_Programs.ipynb index 1bf1a3d7..d4391f66 100644 --- a/lessons/00_Turtles/08a_More_Turtle_Programs.ipynb +++ b/lessons/00_Turtles/08a_More_Turtle_Programs.ipynb @@ -6,6 +6,8 @@ "source": [ "# Learn more about the Turtle\n", "\n", + "( Have you checked in your code? ) \n", + "\n", "We've seen a lot of Turtle programs so far, but there is a lot more to the\n", "Python turtle. Fortunately, there is a list of everything that the Turtle is\n", "capable of: the Python documentation for the turtle module. Visit this site to see\n", diff --git a/lessons/00_Turtles/16_Turtle_Spiral.py b/lessons/00_Turtles/16_Turtle_Spiral.py index bd5ff5d8..f167d58b 100644 --- a/lessons/00_Turtles/16_Turtle_Spiral.py +++ b/lessons/00_Turtles/16_Turtle_Spiral.py @@ -48,3 +48,5 @@ def getRandomColor(): turtle.done() + +# Now check in your code! \ No newline at end of file From 1eb34f9193e269903f81eccfce967424506f260a Mon Sep 17 00:00:00 2001 From: Eric Busboom Date: Thu, 29 Aug 2024 20:52:16 -0700 Subject: [PATCH 3/6] Fixing issues. --- .../06a_Variables_and_Functions.ipynb | 26 +++++++- ...pynb => 06b_Variables_and_Functions.ipynb} | 26 +------- .../00_Turtles/08a_More_Turtle_Programs.ipynb | 65 +++++++++++++++++-- lessons/00_Turtles/12_Color_Lines.py | 2 +- 4 files changed, 86 insertions(+), 33 deletions(-) rename lessons/00_Turtles/{06_Variables_and_Functions.ipynb => 06b_Variables_and_Functions.ipynb} (87%) diff --git a/lessons/00_Turtles/06a_Variables_and_Functions.ipynb b/lessons/00_Turtles/06a_Variables_and_Functions.ipynb index a7e5ec89..9aaa1cc6 100644 --- a/lessons/00_Turtles/06a_Variables_and_Functions.ipynb +++ b/lessons/00_Turtles/06a_Variables_and_Functions.ipynb @@ -6,6 +6,17 @@ "source": [ "# Variables and Functions\n", "\n", + "
\n", + " A few thigns to remember:\n", + "\n", + " 1) Commit your code! Review `03_Check_In_You_Code` for a reminder \n", + " on how to commit and sync your changes. \n", + " 2) Remember that these `.ipynb` files have runable cells. Review `01_Get_Started`, \n", + " in the section \"Running Programs\" for a reminder on how to run code cells in this file. \n", + " \n", + "
\n", + "\n", + "\n", "Here is one of the ways to solve the last assignment, making shapes with a\n", "loop:\n", "\n", @@ -33,9 +44,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "60.0" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Run me\n", "# Compute the angle for a number of sides\n", diff --git a/lessons/00_Turtles/06_Variables_and_Functions.ipynb b/lessons/00_Turtles/06b_Variables_and_Functions.ipynb similarity index 87% rename from lessons/00_Turtles/06_Variables_and_Functions.ipynb rename to lessons/00_Turtles/06b_Variables_and_Functions.ipynb index 9aaa1cc6..a7e5ec89 100644 --- a/lessons/00_Turtles/06_Variables_and_Functions.ipynb +++ b/lessons/00_Turtles/06b_Variables_and_Functions.ipynb @@ -6,17 +6,6 @@ "source": [ "# Variables and Functions\n", "\n", - "
\n", - " A few thigns to remember:\n", - "\n", - " 1) Commit your code! Review `03_Check_In_You_Code` for a reminder \n", - " on how to commit and sync your changes. \n", - " 2) Remember that these `.ipynb` files have runable cells. Review `01_Get_Started`, \n", - " in the section \"Running Programs\" for a reminder on how to run code cells in this file. \n", - " \n", - "
\n", - "\n", - "\n", "Here is one of the ways to solve the last assignment, making shapes with a\n", "loop:\n", "\n", @@ -44,20 +33,9 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "60.0" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Run me\n", "# Compute the angle for a number of sides\n", diff --git a/lessons/00_Turtles/08a_More_Turtle_Programs.ipynb b/lessons/00_Turtles/08a_More_Turtle_Programs.ipynb index d4391f66..d460d6e0 100644 --- a/lessons/00_Turtles/08a_More_Turtle_Programs.ipynb +++ b/lessons/00_Turtles/08a_More_Turtle_Programs.ipynb @@ -130,8 +130,16 @@ "# More than One Turtle\n", "\n", "You can have more than one turtle on the screen. \n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "\n", "```python\n", + "# Double click on this cell to copy the code. \n", "\n", "import turtle as turtle\n", "\n", @@ -151,6 +159,7 @@ "for i in range(-200, 200):\n", " t1.goto(i,i)\n", " t2.goto(i,-i)\n", + "\n", "```" ] }, @@ -160,9 +169,16 @@ "source": [ "# Click on the Screen\n", "\n", - "You can make the turtle do things when you click on the screen. \n", + "You can make the turtle do things when you click on the screen. \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```python\n", "\n", - "```python \n", + "# Double click on this cell to copy the code \n", "\n", "import turtle as turtle\n", "\n", @@ -196,9 +212,18 @@ "source": [ "# Click on the Turtle\n", "\n", - "You can execute a function when the user clicks on the turtle. \n", + "You can execute a function when the user clicks on the turtle. \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "\n", "```python\n", + "\n", + "# Double click on this cell to copy the code\n", + "\n", "import turtle as turtle\n", "\n", "turtle.setup(width=600, height=600)\n", @@ -230,7 +255,13 @@ "\n", "\n", "turtle.done() # Important! Use `done` not `exitonclick` to keep the window open\n", - "```\n", + "```\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "\n", "In the line `t.onclick(lambda x, y, t=t: turtle_clicked(t, x, y))` the\n", "lambda keyword is used to create an anonymous function, a function that does not\n", @@ -244,9 +275,17 @@ "Unfortunately, if you have multiple turtles, you wont be able to tell which\n", "turtle was clicked on in the ``turtle_clicked`` function. Here is one way to\n", "solve that problem, using some advanced Python that we have not learned yet. \n", - "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "\n", "```python\n", + "# Double click on this cell to copy the code\n", + "\n", "import turtle as turtle\n", "\n", "screen = turtle.Screen()\n", @@ -288,8 +327,22 @@ } ], "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, "language_info": { - "name": "python" + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.0" } }, "nbformat": 4, diff --git a/lessons/00_Turtles/12_Color_Lines.py b/lessons/00_Turtles/12_Color_Lines.py index 0c4010b4..a8ea6b54 100644 --- a/lessons/00_Turtles/12_Color_Lines.py +++ b/lessons/00_Turtles/12_Color_Lines.py @@ -24,4 +24,4 @@ ... # Your code here -tina.done() \ No newline at end of file +turtle.exitonclick() # Close the window when we click on it \ No newline at end of file From 56d38ee9aa471ace58eeb36d28b397466b0fab99 Mon Sep 17 00:00:00 2001 From: Eric Busboom Date: Thu, 29 Aug 2024 21:31:51 -0700 Subject: [PATCH 4/6] . --- lessons/00_Turtles/01_Get_Started.ipynb | 12 ++++++++++-- lessons/00_Turtles/03_Check_In_Your_Code.ipynb | 10 ++++++++-- lessons/00_Turtles/06b_Variables_and_Functions.ipynb | 4 ++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lessons/00_Turtles/01_Get_Started.ipynb b/lessons/00_Turtles/01_Get_Started.ipynb index baca5811..11403993 100644 --- a/lessons/00_Turtles/01_Get_Started.ipynb +++ b/lessons/00_Turtles/01_Get_Started.ipynb @@ -86,9 +86,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello 👋 World 🌎 ! Today is August 29, 2024\n" + ] + } + ], "source": [ "import datetime\n", "\n", diff --git a/lessons/00_Turtles/03_Check_In_Your_Code.ipynb b/lessons/00_Turtles/03_Check_In_Your_Code.ipynb index 522bf752..f67ec15a 100644 --- a/lessons/00_Turtles/03_Check_In_Your_Code.ipynb +++ b/lessons/00_Turtles/03_Check_In_Your_Code.ipynb @@ -27,7 +27,7 @@ "\n", "
\n", "\n", - "This is the Source Control icon; click on it to get accecss to the Source Control tool for\n", + "This is the Source Control icon; click on it to get access to the Source Control tool for\n", "checking in your code. Now the Source Control pane should look like this: \n", "\n", "
\n", @@ -66,7 +66,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Remember to check in your code frequently! The best thing to do is check in after every lesson, but you should be especially diligent about checking code in before you finish your lessons for the day. " + "Remember to check in your code frequently! The best thing to do is check in\n", + "after every lesson, but you should be especially diligent about checking code in\n", + "before you finish your lessons for the day. \n", + "\n", + "If you want to force your Codespace to stop, click on the blue area in the lower\n", + "left corner. That will pop up a menu ( at the top of the screen ) with options\n", + "to stop the codespace. \n" ] }, { diff --git a/lessons/00_Turtles/06b_Variables_and_Functions.ipynb b/lessons/00_Turtles/06b_Variables_and_Functions.ipynb index a7e5ec89..26491f25 100644 --- a/lessons/00_Turtles/06b_Variables_and_Functions.ipynb +++ b/lessons/00_Turtles/06b_Variables_and_Functions.ipynb @@ -93,8 +93,8 @@ "source": [ "# Functions\n", "\n", - "We can make another more improvement in our program; by grouping \n", - "the comands to create a shape into a __function__. Here is an example of a function:" + "We can make another improvement in our program; by grouping \n", + "the commands to create a shape into a __function__. Here is an example of a function:" ] }, { From 61fc872bd75097d8c6d61861046398621277e4a0 Mon Sep 17 00:00:00 2001 From: Eric Busboom Date: Sun, 6 Oct 2024 19:14:20 -0700 Subject: [PATCH 5/6] . --- lessons/00_Turtles/01_Get_Started.ipynb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lessons/00_Turtles/01_Get_Started.ipynb b/lessons/00_Turtles/01_Get_Started.ipynb index 11403993..f95fa153 100644 --- a/lessons/00_Turtles/01_Get_Started.ipynb +++ b/lessons/00_Turtles/01_Get_Started.ipynb @@ -86,25 +86,25 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Hello 👋 World 🌎 ! Today is August 29, 2024\n" + "Hello 👋 World 🌎 ! Today is 2024-08-29\n" ] } ], "source": [ "import datetime\n", "\n", - "date = datetime.date.today().strftime(\"%B %d, %Y\")\n", - "s = F\"Hello 👋 World 🌎 ! Today is {date}\"\n", + "date = datetime.date.today() # Get the Date\n", "\n", + "s = F\"Hello 👋 World 🌎 ! Today is\" # Make a string with a message and the date\n", "\n", - "print(s)" + "print(s, date) # Print the string. " ] }, { @@ -204,7 +204,7 @@ ], "metadata": { "kernelspec": { - "display_name": ".venv", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -218,9 +218,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.0" + "version": "3.11.6" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } From 2d04521cda46fe24c159985a565429f9848250e6 Mon Sep 17 00:00:00 2001 From: Eric Busboom Date: Sun, 6 Oct 2024 19:23:19 -0700 Subject: [PATCH 6/6] . --- ...ipynb => 06_Variables_and_Functions.ipynb} | 2 +- .../06b_Variables_and_Functions.ipynb | 161 ------------------ 2 files changed, 1 insertion(+), 162 deletions(-) rename lessons/00_Turtles/{06a_Variables_and_Functions.ipynb => 06_Variables_and_Functions.ipynb} (98%) delete mode 100644 lessons/00_Turtles/06b_Variables_and_Functions.ipynb diff --git a/lessons/00_Turtles/06a_Variables_and_Functions.ipynb b/lessons/00_Turtles/06_Variables_and_Functions.ipynb similarity index 98% rename from lessons/00_Turtles/06a_Variables_and_Functions.ipynb rename to lessons/00_Turtles/06_Variables_and_Functions.ipynb index 9aaa1cc6..7c06f670 100644 --- a/lessons/00_Turtles/06a_Variables_and_Functions.ipynb +++ b/lessons/00_Turtles/06_Variables_and_Functions.ipynb @@ -23,7 +23,7 @@ "```python \n", "\n", "import turtle # Tell Python we want to work with the turtle\n", - "turtle.setup(width=600, height=600, startx=0, starty=0) # Set the size of the window\n", + "turtle.setup(width=600, height=600) # Set the size of the window\n", "\n", "tina = turtle.Turtle() # Create a turtle named tina\n", "\n", diff --git a/lessons/00_Turtles/06b_Variables_and_Functions.ipynb b/lessons/00_Turtles/06b_Variables_and_Functions.ipynb deleted file mode 100644 index 26491f25..00000000 --- a/lessons/00_Turtles/06b_Variables_and_Functions.ipynb +++ /dev/null @@ -1,161 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Variables and Functions\n", - "\n", - "Here is one of the ways to solve the last assignment, making shapes with a\n", - "loop:\n", - "\n", - "```python \n", - "\n", - "import turtle # Tell Python we want to work with the turtle\n", - "turtle.setup(width=600, height=600, startx=0, starty=0) # Set the size of the window\n", - "\n", - "tina = turtle.Turtle() # Create a turtle named tina\n", - "\n", - "for i in range(4):\n", - " tina.forward(150) # Move tina forward by the forward distance\n", - " tina.left(90) # Turn tina left by the left turn\n", - "\n", - "\n", - "```\n", - "\n", - "Let's see if we can make this code even simpler. Notice that the code that draws\n", - "the square has a range of `4` and left turn of `90` degrees, and $4*90 = 360$,\n", - "and there are 360 degrees in a circle. The pentagram has a range of `5` and a\n", - "left turn of `72` degrees, and $5*72=360$. Hmm... could we come up with a way to\n", - "compute the angle for any number of sides? To do that, we going to use\n", - "variables and math. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Run me\n", - "# Compute the angle for a number of sides\n", - "\n", - "sides = 6\n", - "angle = 360/sides\n", - "\n", - "angle\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If we want 6 sides the angle is 60 degrees, and sure enough, $60*6 = 360$.\n", - "\n", - "The words `sides` and `angle` are __variables__, which are like the names of boxes \n", - "that can hold values. We can __assign__ values to variables, then use those variables \n", - "in other places. \n", - "\n", - "```python \n", - "\n", - "sides = 4\n", - "angle = 360/sides # Calculate the angle from the number of sides. \n", - "\n", - "for i in range(sides):\n", - " tina.forward(150) # Move tina forward by the forward distance\n", - " tina.left(angle) # Turn tina left by the left turn\n", - "\n", - "```\n", - "\n", - "In this program, if you change the number that we assign to `sides`, the angle will change automatically!\n", - "\n", - "Let's see if the angles created by this equation seem correct. Fill in the\n", - "'...' in the program in the cell below to calculate angles from sides: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Run me!\n", - "\n", - "for sides in range(1, 10):\n", - " angle = ...\n", - " print(\"Angle for \", sides, \" sides is \", angle)\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Functions\n", - "\n", - "We can make another improvement in our program; by grouping \n", - "the commands to create a shape into a __function__. Here is an example of a function:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def say_hello(name, times): # define the function, and give it a name. 'name' and 'times' are parameters\n", - "\n", - " for i in range(times): # This is the body of the function\n", - " print(i, \"Hello \", name)\n", - "\n", - "say_hello(\"John\", 5) # Call the function, and pass it two arguments" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The line that starts with 'def' is the start of the function definition, and the\n", - "last line is where we call the function -- we actually run it. Try calling the\n", - "function again with different parameters." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "say_hello('bob',3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": ".venv", - "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.0" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}