Files
lab_names/shapes.py
jwberent 8dfa384f43 I already submitted the changes I made in checkpoint 1 so please let me know if I need to rewrite the changes I made in checkpoint 1 since I am saving it again. I will only be talking about checkpoint 2 now. I removed the pass in the triangle and rectangle functions and added the necessary code by using right and forward in the turtle library to make triangles and rectangles appear.
Checkpoint 2:
-A function is like a variable in that it allows you to save code that will be ran everytime you call it.
-Functions can break down big problems by allowing you to run the same thing over and over by just calling it.  An example would be coding a house.  This chould be accomplished by making a door function, triangle function, and rectangle function which could be used for the walls and smaller rectangles that could be used for the windows.
2025-09-05 14:57:41 -04:00

25 lines
382 B
Python

# shapes.py
# ---------
# By MWC contributors
from turtle import *
def triangle(side_length):
forward(side_length)
right(120)
forward(side_length)
right(120)
forward(side_length)
right(120)
def rectangle(height, width):
forward(width)
right(90)
forward(height)
right(90)
forward(width)
right(90)
forward(height)
right(90)