Catalogue of Posts

Tuesday, September 1, 2020

Basic Graphics #4 - Square

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



For i in range(4):
    Pt.forward(number of pixels)
    Pt.right(90)

    A square always has 
      -    4  equal sides
      -    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
    
    for i in range(number of times):          
          Pt.forward(number of pixels)        
          Pt.right(90)

 
The loop, outside, makes copies, a number of times
f
or 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)













THE FOUR QUADRANTS


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".







THE GRID


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.



POINTS ON THE GRID


Where the lines meet,
we can call those “points”.

0    The Origin, is a point.

We can say,
0    The Origin, is at,
x  =  0    and,
y  =  0

We can write its position as,
    (0,0)  

For any point on the grid,
we can write its position as,
    (x,y)  




(c) Katherine Stuart 2020
Dochas Books Film 

No comments:

Post a Comment