Question: python coding Read the x and y coordinates of points from the file points 3 . txt into the lists x and y . .

python coding
Read the x and y coordinates of points from the file points3.txt into the lists x and y.. Make sure you download and save that file into your working folder first, of course.
Create a list of Point objects from those coordinates. Here, you cannot simply type a command to append each Point object to p_list explicitly, as we did in Task 1. There are two many points (1095 to be exact) to type an append command for each. Instead, you need to append them all using a for-loop, similar to the for-loop in Task 2. This part is the main part for you to figure out!
Here is my code so far
from graphics import *
def main():
fileName = "points3.txt"
infile = open(fileName,'r')
x=[]
y=[]
line = infile.readline()
for xStr in line.split(","):
x.append(float(xStr))
line = infile.readline()
for yStr in line.split(","):
y.append(float(yStr))
for i in range(len(x)):
print(f'point: ({x[i]},{y[i]})')
win = GraphWin("Connecting Dots - Melissa Carpenter", 500,500)
win.setCoords(0,0,800,800)
win.setBackground("lightyellow")
poly.draw(win)
poly.setFill("lightblue")
win.getMouse()
win.close()
main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!