Using - The Python Computer Language
              Turtle Graphics Library
4.  SQUARE
SAVE AS
 
>>> import turtle
>>>
>>> Pt = turtle.Turtle()
>>>
>>> for i in range(4):
Pt.forward(200)
Pt.right(90)
 
    
>>>
>>> turtle.done()
>>> 
  
SAVE
>>> import turtle
>>>
>>> Pt = turtle.Turtle()
>>>
>>> for i in range(4):
Pt.forward(200)
Pt.right(90)
>>>
>>> turtle.done()
>>>
SAVE
For i in range(4):
Pt.forward(number of pixels)
Pt.right(90)
A square always has
 
- 90 degree angles
 
Pt.forward(number of pixels)
Pt.right(90)
A square always has
- 90 degree angles
A LOOP WITHIN A LOOP
Something which is made by a loop,
can be copied in another position,
numerous times by another loop.
for i in range(number of times): ENTER
    for i in range(number of
times):        ENTER
         
Pt.forward(number of pixels) ENTER
Pt.right(90) ENTER, BACKSPACE ONCE
Pt.right(90) ENTER
 
 
The loop, inside, makes the square –
    
Pt.forward(number of pixels) ENTER
Pt.right(90) ENTER, BACKSPACE ONCE
Pt.right(90) ENTER
The loop, inside, makes the square –
    for
i in range(number of times):           
Pt.forward(number of pixels)
Pt.right(90)
Pt.forward(number of pixels)
Pt.right(90)
The loop, outside, makes copies, a number of times –
for i in range(number of times):
This changes the start angle for the next square, a further 90 degrees each time –
Pt.right(90)
TWO SQUARES
SAVE AS
>>> import turtle
>>>
>>> Pt = turtle.Turtle()
>>>
>>> for i in range(2):
for i in range(4):
Pt.forward(200)
Pt.right(90)
Pt.right(90)
>>> turtle.done()
>>>
SAVE
THREE SQUARES
SAVE AS
>>> import turtle
>>> 
>>> Pt =
turtle.Turtle()
>>>  
>>> for i in
range(3):
     for i in range(4):
          Pt.forward(200)
          Pt.right(90)
     Pt.right(90)
>>>  
>>> turtle.done()
>>>
SAVE
FOUR SQUARES
SAVE AS
>>> import turtle
>>> 
>>> Pt =
turtle.Turtle()
>>> 
>>> for i in
range(4):
     for i in range(4):
          Pt.forward(200)
          Pt.right(90)
     Pt.right(90)
>>> 
>>> turtle.done()
>>>
SAVE
Four Squares -
For i in range(4):
    For i in range(4):
        Pt.forward(number
of              pixels)
        Pt.right(90)
    Pt.right(90)
In this arrangement  -
Each square is called a  quadrant.
"Quad"    means     "four".
The quadrant is the space,
also known as the "area".
This is how I have numbered them.
0    is the    "Origin".
If
we look at the lines,
each
square has equal sides,
and
all the squares are the same.
We can say that each side is
1
“unit”, or amount.
Then,
we can say, 
all
the horizontal lines are    X
and,
all the vertical lines are    Y
We
can also say,
that    X    to the right of    0,
And    Y 
  above    0,
have
positive    “+” 
  numbers,
adding
to    0.
And,
that    X  
 to the left of    0,
and    Y    below 
  0,
have negative    “-“ 
  numbers,
taking away from   
0.











 
No comments:
Post a Comment