generated from mwc/lab_names
Fucntions can be helpful in breaking down big prolblems as you can assign them a specific value, which helps save time and helps make the code less clunky and long. A variable is used for a short hand of a value for example a variable could be X and X could be defined as something like (hello) which would then shape into a bigger code if ever need be repeated.
30 lines
387 B
Python
30 lines
387 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)
|
|
|
|
|
|
|
|
|
|
|