I get an error when trying to make this program.

``````from pointLine import *

def calcSlope(x1,y1, x2,y2):
slope = (x2-x1)/(y2-y1)
return slope

def calcPointOnLine(y, m, x, b):
if  y == (m*x)+ b:
return True
else:
return False

print "Point is on a Line? Program"

line1 = [(1,7), (7,19)]
x1 = line1[0][0]
x2 = line1[1][0]
y1 = line1[0][1]
y2 = line1[1][1]

slope1 = calcSlope(x1,y1,x2,y2)
yIntercept = y1 - (((y2 - y1)/(x2 - x1))(x1))

p1 = Point(3,11)
pointY1 = p1.y
pointX1 = p1.x

print "Point(3,11) is on line", line1, ":", \
calcPointOnLine(pointY1, slope1, pointX1, yIntercept)

p2 = Point(4,11)
pointX2 = p2.x
pointY2 = p2.y

print "Point(4,11) is on line", line1, ":", \
calcPointOnLine (pointY2, slope1, pointX2, yIntercept)``````

``````Traceback (most recent call last):
File "C:\Users\Me\assignment.py", line 22, in <module>
yIntercept = y1 - (((y2 - y1)/(x2 - x1))(x1))
TypeError: 'int' object is not callable``````
3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by Mazille

It appears that you omitted an operator:
yIntercept = y1 - (((y2 - y1)/(x2 - x1))(add operator here)(x1))

sharp eye, nice

`yIntercept = y1 - (((y2 - y1)/(x2 - x1))(x1))`

Yes, Python is not a scientific calculator so it does not know that `(x-5)(x-4)` has an assumed multiplication between parenthesis. You will need to be more specific so change your line to

``````yIntercept = y1 - ( ( ( y2 - y1 ) / ( x2 - x1 ) ) * ( x1 ) )
``````

Edited by mike_2000_17: Fixed formatting