Working with Mike G. and the teacher on this project made it a lot more easy to tackle. I decided to stick with the cactus theme from the first assignment of the course and created a potted cactus plant.

This commit is contained in:
R Marshall Hall
2023-07-29 14:23:56 -04:00
parent 75f7d118cc
commit 4ed6f56184
2 changed files with 63 additions and 12 deletions

View File

@@ -5,3 +5,54 @@
# (Briefly describe what this program does.)
from turtle import *
def square(unit):
"Draws a square of size unit"
begin_fill()
for side in range(4):
forward(unit)
right(90)
end_fill()
def row_of_squares(unit, quantities_and_colors):
"Draws a row of squares, one in each color in colors"
squares_traveled = 0
for quantity, color in quantities_and_colors:
fillcolor(color)
for each_square in range(quantity):
square(unit)
forward(unit)
squares_traveled = squares_traveled + 1
return_to_baseline(unit, squares_traveled)
def return_to_baseline(unit, count):
right(180)
penup()
forward(unit * count)
left(90)
forward(unit)
left(90)
pendown()
drawing_size = 10
penup()
goto(-200, 0)
pendown()
data = [
[[10, "white"]],
[[4, "white"], [2, "green"], [4, "white"]],
[[3, "white"], [1, "pink"], [1, "red"], [2, "green"], [3, "white"]],
[[1, "white"], [1, "green"], [1, "white"], [2, "red"], [2, "green"], [1, "white"], [1, "pink"], [1, "white"]],
[[1, "white"], [8, "green"], [1, "white"]],
[[3, "white"], [5, "green"], [2, "white"]],
[[3, "white"], [4, "green"], [3, "white"]],
[[2, "white"], [6, "brown"], [2, "white"]],
[[3, "white"], [4, "brown"], [3, "white"]],
[[3, "white"], [4, "brown"], [3, "white"]],
]
for row in data:
row_of_squares(drawing_size, row)