I really need help. The output is supposed to read a text file with the coordinates and print them to a text file, but I am not sure what lines of code to write and where to insert them.
Here are the coordinates that are in there own text file:
1,16,10,31
2,12,21,9
3,7,8,25
4,5,15,3
5,1,6,3
def findSlope (x1, y1, x2, y2):
rise = y2 - y1
run = x2 - x1
if run == 0:
slope = "undefined"
else:
slope = rise/run
return slope
import sys, string
inFile = open("C:\Python\coordinates.txt", "r")
outFile = open("output.txt", "w")
for i in inFile:
origin = i.split(',')
j=0
for j in range(len(origin)):
origin[j] = str.strip(str(origin[j]), "\n")
inFile2 = open("C:\Python\coordinates1.txt", "r")
for k in inFile2:
if k!=i:
destination = k.split(',')
e=0
for e in range(len(destination)):
destination[e] = str.strip(str(destination[e]), "\n")
print origin
print destination
print findSlope(int(origin[1]), int(destination[1]), int(origin[2]), int(destination[2]))
inFile2.close()
outFile2.close()
inFile.close()
outFile.close()