generated from mwc/lab_names
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.
29 lines
402 B
Python
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)
|
|
|
|
|