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)

Here's the dreaded error message:

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

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

commented: sharp eye, nice +8

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 ) )

ohhh I forgot about that!!
I actually had copied and pasted that statement.
Thank you very much solsteel and jlm699!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.