diff --git a/lessons/00_Turtles/01_Get_Started.ipynb b/lessons/00_Turtles/01_Get_Started.ipynb index aa7e7a3d..f95fa153 100644 --- a/lessons/00_Turtles/01_Get_Started.ipynb +++ b/lessons/00_Turtles/01_Get_Started.ipynb @@ -86,17 +86,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "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. " ] }, { @@ -151,14 +159,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, @@ -169,7 +204,7 @@ ], "metadata": { "kernelspec": { - "display_name": ".venv", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -183,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 } 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/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/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/06a_Variables_and_Functions.ipynb b/lessons/00_Turtles/06a_Variables_and_Functions.ipynb deleted file mode 100644 index 27d37bbf..00000000 --- a/lessons/00_Turtles/06a_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) # 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 more improvement in our program; by grouping \n", - "the comands 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 -} 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/08a_More_Turtle_Programs.ipynb b/lessons/00_Turtles/08a_More_Turtle_Programs.ipynb index 1bf1a3d7..d460d6e0 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", @@ -128,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", @@ -149,6 +159,7 @@ "for i in range(-200, 200):\n", " t1.goto(i,i)\n", " t2.goto(i,-i)\n", + "\n", "```" ] }, @@ -158,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", @@ -194,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", @@ -228,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", @@ -242,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", @@ -286,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/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..a8ea6b54 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 @@ -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 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/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 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