-
Notifications
You must be signed in to change notification settings - Fork 0
/
11 - Connect the Dots.py
46 lines (37 loc) · 1.06 KB
/
11 - Connect the Dots.py
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
41
42
43
44
45
46
#Tara Moses
#Assignment 11: Connect the Dots
#February 22, 2013
#1. Program draws a picture according to the points in the file.
import turtle,Tkinter
screen=turtle.Screen()
screen.bgcolor("red")
x_coordinates_array=[]
y_coordinates_array=[]
file_of_dots=file("ConnectDots.txt")
for line in file_of_dots:
line=line.strip()
coordinates=line.split(" ")
x,y=coordinates
x=int(x)
y=int(y)
x_coordinates_array.append(x)
y_coordinates_array.append(y)
turtle.fill(True)
for i in range(len(x_coordinates_array)):
if i==0:
turtle.up()
turtle.goto(x_coordinates_array[i],y_coordinates_array[i])
turtle.down()
turtle.goto(x_coordinates_array[i],y_coordinates_array[i])
turtle.fill(False)
turtle.up()
turtle.color("white")
turtle.fill(True)
for i in range(len(x_coordinates_array)):
if i==0:
turtle.up()
turtle.goto(x_coordinates_array[i]/2.0,y_coordinates_array[i]/2.0)
turtle.down()
turtle.goto(x_coordinates_array[i]/2.0,y_coordinates_array[i]/2.0)
turtle.fill(False)
turtle.mainloop()