In this project I had to change many lines to get

my shapes to work properly. I managed to get one shape to work properly
but the other I was not so fortunate to have work.

Checkpoint 1:

A value is the actual data, like the number 5 or the text "Angelo".
A name is a label that refers to that value, like a variable in Python.
For example, in my_name = "Angelo", the value is "Angelo" and the name is my_name.
An everyday example is a mailbox: the name on the mailbox shows whose mail it is, while the letters inside are the actual contents.
Changing the name doesn't change the letters, so it's important to distinguish between the two.

Variables are useful in programming because they let you give a name to a value, making your code easier to read, understand, and reuse.
Instead of repeatedly typing the same value, you can use a name that represents it,
which makes it easier to update the value in one place if it changes.

Checkpoint 2:

A function is like a variable because it has a name that refers to a piece of code, just like a variable has a name that refers to a value.
Once you define a function, you can use its name to run the code it contains, without rewriting the same instructions each time.
Functions are useful for breaking down big problems because they allow you to divide a large task into smaller, manageable steps.
For example, if you are writing a program to calculate the area and perimeter of many circles,
you could create one function to calculate the area and another to calculate the perimeter.
Then, you can call these functions whenever you need them, instead of rewriting the formulas each time.
This commit is contained in:
angelotr
2025-09-02 00:04:27 -04:00
parent a611163e21
commit cc35815a1a

View File

@@ -2,10 +2,53 @@
# ---------
# By MWC contributors
from turtle import *
import turtle
import math
def triangle(side_length):
pass
# Set up the turtle
t = turtle.Turtle()
t.speed(3)
t.hideturtle()
def rectangle(height, width):
pass
# Draw triangle with lines (left side, unfilled)
t.penup()
t.goto(-200, 0)
t.pendown()
for _ in range(3): # Unfilled triangle
t.forward(200)
t.left(120)
# Draw internal diagonal lines
t.penup()
t.goto(-200, 0) # Bottom-left
t.pendown()
t.goto(-100, 100 * math.sqrt(3)) # Top
t.penup()
t.goto(-200, 0) # Bottom-left
t.pendown()
t.goto(0, 100 * math.sqrt(3)) # Top-right
t.penup()
t.goto(0, 100 * math.sqrt(3)) # Top-right
t.pendown()
t.goto(-200, 0) # Bottom-left
# Move to a separate position for upside-down rectangle grid (right side)
t.penup()
t.goto(100, 225) # Start at the top for upside-down grid
t.pendown()
# Draw upside-down smaller grid rectangle with 9 units length, decreasing to 1
unit = 25 # Unit size is 25 pixels for a smaller rectangle
for i in range(9): # 9 rows, starting from top and decreasing
for j in range(9 - i): # Decreases from 9 to 1
t.penup()
t.goto(100 + j * unit, 225 - i * unit) # Invert y-coordinate for upside-down
t.pendown()
for _ in range(4):
t.forward(unit)
t.right(90)
# Keep window open
turtle.done()