| | |
Help! Finding a point on a line program
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2008
Posts: 10
Reputation:
Solved Threads: 0
I get an error when trying to make this program.
Here's the dreaded error message:
python Syntax (Toggle Plain Text)
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:
python Syntax (Toggle Plain Text)
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
Last edited by Mazille; Jul 13th, 2008 at 10:23 pm.
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
python Syntax (Toggle Plain Text)
yIntercept = y1 - ( ( ( y2 - y1 ) / ( x2 - x1 ) ) * ( x1 ) )
![]() |
Similar Threads
- Error loading cmicnfg.cpl -- SOLUTION HERE! (Windows NT / 2000 / XP)
- help finding line in file! (C++)
- project plz who can help me (C++)
- who can help me in c++ project (C++)
- Finding length (Java)
- XP Boot problems due to virus? (Viruses, Spyware and other Nasties)
- Possible Data Lost, Help! (Windows 95 / 98 / Me)
Other Threads in the Python Forum
- Previous Thread: If <not number>?
- Next Thread: Directory Picker Control(BOA Constructor)
| Thread Tools | Search this Thread |
Tag cloud for Python
abrupt ansi anti approximation assignment avogadro backend basic beginner binary bluetooth calculator character code customdialog decimals dictionaries dictionary drive dynamic examples excel exe file float format ftp function gnu graphics gui heads homework http ideas import input java launcher leftmouse line linux list lists loop module mouse number numbers output parsing path pointer port prime program programming progressbar projects py2exe pygame pyqt python random recursion recursive refresh schedule scrolledtext sqlite ssh statistics stdout string strings sudokusolver sum table terminal text thread threading time tkinter tlapse tricks tuple tutorial twoup ubuntu unicode update urllib urllib2 variable wikipedia windows write wxpython xlib






