I modified the code to draw a green heart with a

pink arrow going through it. This process included tasks such as roation, color changes and using the penup/pendown commands.

At first I felt a bit frustrated because I couldm't really figure out the UI, since I used Python only in Jupyter Notebook before.
I also felt confused when I was trying to figure out the initial oritentation of the "pen". Once I figured that out, it was smooth sailing.
It felt funny to need geometry after a long time not needing it. Once I was done, I felt happy!
This commit is contained in:
caglazir
2025-09-05 22:14:09 -04:00
parent 49edc2971e
commit 6a174f9dd7
2 changed files with 42 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
import math
from turtle import ( from turtle import (
forward, forward,
back, back,
@@ -8,15 +9,43 @@ from turtle import (
color, color,
) )
color("PaleGreen")
right(315)
forward(300)
left(45)
forward(100) forward(100)
right(360 * 2 / 5) left(45)
forward(100) forward(100)
right(360 * 2 / 5) left(45)
forward(100) forward(100)
right(360 * 2 / 5) left(45)
forward(100) forward(100)
right(360 * 2 / 5) right(90)
forward(100) forward(100)
right(360 * 2 / 5) left(45)
forward(100)
left(45)
forward(100)
left(45)
forward(100)
left(45)
forward(300)
left(45)
forward(60)
penup()
back(300/(math.sqrt(2)))
color("DeepPink")
pendown()
right(135)
back(600)
right(90)
forward(5)
right(135)
forward(5*(math.sqrt(2)))
right(90)
forward(5*(math.sqrt(2)))
right(135)
forward(5)
input() input()

7
poetry.lock generated Normal file
View File

@@ -0,0 +1,7 @@
# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand.
package = []
[metadata]
lock-version = "2.1"
python-versions = ">=3.10,<4.0"
content-hash = "7b8fc01b274bd807fb00372bbc8e138330f15ae7978ed61e180f3b17ec076725"