generated from mwc/lab_names
In the 1st section, I first changed chris to my name, then changed it to an input equation, then i changed the circle area code by putting in the number pi and the equation for the area of a circle and then printed that. In the second section I changed the traingle to make 60 degree turns because that would make a equaliateral triangle in my mind, then i realised to make a 60 degree intertior angle it has to turn 120 degrees so i changed that next, then i had the rectangle turn 90 degrees each time, i told the shapes files to do 2 different sized triangles and 1 rectangle. I ran it with test and with draw with and by its self
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.
This commit is contained in:
22
shapes.py
22
shapes.py
@@ -5,7 +5,25 @@
|
||||
from turtle import *
|
||||
|
||||
def triangle(side_length):
|
||||
pass
|
||||
forward(side_length)
|
||||
right(120)
|
||||
forward(side_length)
|
||||
right(120)
|
||||
forward(side_length)
|
||||
right(120)
|
||||
|
||||
def rectangle(height, width):
|
||||
pass
|
||||
forward(height)
|
||||
right(90)
|
||||
forward(width)
|
||||
right(90)
|
||||
forward(height)
|
||||
right(90)
|
||||
forward(width)
|
||||
right(90)
|
||||
|
||||
triangle(20)
|
||||
|
||||
triangle(40)
|
||||
|
||||
rectangle(40,20)
|
||||
|
||||
Reference in New Issue
Block a user