generated from mwc/lab_names
In a computer program a function can be used many times, just like a variable, with different input values and different output values possible. In modular programmimg and object-oriented programming, hundreds or even thousands of functions can be "called" by a main program, such as a large program that calculates your Federal IRS 1040 Income Tax each year. The program has to be updated each year for changes in the current year tax laws.
24 lines
385 B
Python
24 lines
385 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)
|