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.
This commit is contained in:
jbayati
2025-09-25 09:28:25 -04:00
parent 92c7b2556c
commit 99df846f7c

View File

@@ -15,6 +15,14 @@ def triangle(side_length):
def rectangle(height, width): def rectangle(height, width):
pass
forward(height)
right(90)
forward(width)
right(90)
forward(height)
right(90)
forward(width)
right(90)