diff --git a/lessons/10_Turtles/10_Welcome/10_Welcome.ipynb b/lessons/10_Turtles/10_Welcome/10_Welcome.ipynb index e733bb09..c14a4eb6 100644 --- a/lessons/10_Turtles/10_Welcome/10_Welcome.ipynb +++ b/lessons/10_Turtles/10_Welcome/10_Welcome.ipynb @@ -36,7 +36,7 @@ ], "metadata": { "kernelspec": { - "display_name": ".venv", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -50,7 +50,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.11" + "version": "3.12.13" }, "syllabus": { "uid": "RRTPqCQu" diff --git a/lessons/10_Turtles/20_Introducing_Tina/30_Squares_and_Circles/Squares_and_Circles.py b/lessons/10_Turtles/20_Introducing_Tina/30_Squares_and_Circles/Squares_and_Circles.py index 7e22ab03..5417079d 100644 --- a/lessons/10_Turtles/20_Introducing_Tina/30_Squares_and_Circles/Squares_and_Circles.py +++ b/lessons/10_Turtles/20_Introducing_Tina/30_Squares_and_Circles/Squares_and_Circles.py @@ -3,10 +3,7 @@ lines that start with a # are comments. They are not executed by Python. The lines inside the three quotes are also comments, but of a different sort ( called "doc comments" ) Comments are used to explain what the code does. Read -the program and try to understand what each line does. -""" - -import turtle # Tell Python we want to work with the turtle +the program and try to understand what each line does. # Tell Python we want to work with the turtle turtle.setup(600,600,0,0) # Set the size of the window tina = turtle.Turtle() # Create a turtle named tina diff --git a/lessons/10_Turtles/60_More_Turtle_Programs/10_More_Turtle_Programs.ipynb b/lessons/10_Turtles/60_More_Turtle_Programs/10_More_Turtle_Programs.ipynb index 7ebc70f4..ade6161d 100644 --- a/lessons/10_Turtles/60_More_Turtle_Programs/10_More_Turtle_Programs.ipynb +++ b/lessons/10_Turtles/60_More_Turtle_Programs/10_More_Turtle_Programs.ipynb @@ -326,7 +326,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.11" + "version": "3.12.13" }, "syllabus": { "uid": "IloYptI2" diff --git a/lessons/10_Turtles/60_More_Turtle_Programs/20_More_Turtle_programs.py b/lessons/10_Turtles/60_More_Turtle_Programs/20_More_Turtle_programs.py index 8a27e9bf..bd88c88b 100644 --- a/lessons/10_Turtles/60_More_Turtle_Programs/20_More_Turtle_programs.py +++ b/lessons/10_Turtles/60_More_Turtle_Programs/20_More_Turtle_programs.py @@ -4,4 +4,34 @@ Then change the code so that the turtle has a different image ( look in the 'images' directory ) and moves to the corners of the screen in a square pattern. -""" \ No newline at end of file +""" + +import turtle +def set_turtle_image(turtle, image_name): + """set the turtles shape to a custom imagen.""" + from pathlib import Path + image_dir = Path(__file__).parent.parent /"images" + image_path = str(image_dir / image_name) + + screen = turtle.getscreen() + screen.addshape(image_path) + turtle.shape(image_path) + +#set up the screen +screen = turtle.screen() +screen.setup(width=600, height=600) + +# create a turtle and set its shape to the custom gif +t = turtle.turtle() + +set_turtle_image(t, "pikachu.gif") + +t.penup() +t.speed(3) + +for i in range(4): + t.goto(200, 200) + t.goto(-200, -200) + + +turtle.exitonclick() \ No newline at end of file