Files
lab_names/shapes.py
jbayati 99df846f7c A function is similar to a variable because both work coherently.
Functions can be helpful in breaking down big problems as you can assign them a specific value so you can use the function instead of continous copy and paste. Which helps save time and helps make the code less cluttered.
A example is giving the function a specific variable such as (X = Y (line of code)) that you can use in smaller bits of code to help break it down.
2025-09-25 09:28:25 -04:00

29 lines
402 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(height)
right(90)
forward(width)
right(90)
forward(height)
right(90)
forward(width)
right(90)