-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_first_object.py
More file actions
41 lines (33 loc) · 872 Bytes
/
my_first_object.py
File metadata and controls
41 lines (33 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Adapted from Think Python 2, by Allen Downey. Chapter 4
"""
import turtle
def square(my_agent):
""" Receives a turtle and moves it in a square
Specifically, not using for (yet)
"""
my_agent.speed(1)
my_agent.fd(100)
my_agent.lt(90)
my_agent.fd(100)
my_agent.lt(90)
my_agent.fd(100)
my_agent.lt(90)
my_agent.fd(100)
# Emphasize the notion of an OBJECT
# my_agent.lt(90)
def dif_square(my_agent, x, y):
""" Receives a turtle, moves to a fixed position and draws a square in red"""
my_agent.speed(1)
my_agent.color('green')
my_agent.pensize(2)
my_agent.penup()
print(x, y)
my_agent.setpos(x, y)
my_agent.pendown()
square(my_agent)
if __name__ == '__main__':
tuga = turtle.Turtle()
for i in range(7):
dif_square(tuga, 19 * i, 19 * i)
turtle.mainloop()