generated from mwc/lab_names
A value is something we want to use, either a number or an equation. A name is a what we use to refer to that value. A real life situation that comes to my mind, is a shopping cart, the value is something you push around a grocery store to collect grocery items. The name in my area is a shopping cart but i have heard others call it a buggie, a trolley, or a carriage, as the name of something can be changed. If you are using a name to refer to an equation like we did with the area of a circle, equations can get quite long and complicated to write, especailly on a computer, naming allows you to write it once but use it over and over again quickly and easily. It is exactly the same but instead of recalling one thing, it recalls a bunch of things to do together I would guess that we could use functions together for a big problem, solve one little problem with one fuction, a different little problem with a different function and so on I am having trouble thinking of an exmaple of this right now, but i look forward to learning one.
30 lines
427 B
Python
30 lines
427 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)
|
|
|
|
triangle(20)
|
|
|
|
triangle(40)
|
|
|
|
rectangle(40,20)
|