Files
project_drawing/shapes.py
angelotr 6966760b2b My third commit will consist of my third round of changes. What has changed during my third commit were my functions. In this attempt I was given feedback to consider how can I add more parameters or loops to my existing code. I did both by adding customizable parameters to allow a house and sun of any color. I also added a for loop that gives me three houses of different color instead of one.
What got me stuck in the beginning was how can I add more parameters or loops to my existing code.
What I figured out was that by adding more parameters and loops to my existing code I would be able to create a drawing that would give me three house and a sun
with customizable color of my choosing. A strategy I used to get unstuck was to continue using ideas from previous lessons about parameters and trial and error to
 see where things went right and wrong. What I wonder is how can I use super turtle to create an animated sun. What I want to learn more about is how to properly
 use super turtle. Since I have more houses and sun with customizable color my future project idea could be to create three houses and a sun with customizable
 coloring but this time using super turtle to creaete an animated rising sun.
2025-10-05 17:35:20 -04:00

50 lines
1.2 KiB
Python

import turtle
def draw_square(pen, size, color="black", fill=None):
"""Draw a square with optional fill color."""
pen.color(color)
if fill:
pen.fillcolor(fill)
pen.begin_fill()
for _ in range(4):
pen.forward(size)
pen.right(90)
if fill:
pen.end_fill()
def draw_rectangle(pen, width, height, color="black", fill=None):
"""Draw a rectangle with optional fill color."""
pen.color(color)
if fill:
pen.fillcolor(fill)
pen.begin_fill()
for _ in range(2):
pen.forward(width)
pen.right(90)
pen.forward(height)
pen.right(90)
if fill:
pen.end_fill()
def draw_triangle(pen, size, color="black", fill=None):
"""Draw an equilateral triangle with optional fill color."""
pen.color(color)
if fill:
pen.fillcolor(fill)
pen.begin_fill()
for _ in range(3):
pen.forward(size)
pen.left(120)
if fill:
pen.end_fill()
def draw_circle(pen, radius, color="black", fill=None):
"""Draw a circle with optional fill color."""
pen.color(color)
if fill:
pen.fillcolor(fill)
pen.begin_fill()
pen.circle(radius)
if fill:
pen.end_fill()