Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
noob question for Python
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
li1_getoo
l33t
l33t


Joined: 20 Oct 2002
Posts: 661
Location: Queens , NY

PostPosted: Sun Jan 12, 2003 3:36 am    Post subject: noob question for Python Reply with quote

Code:
#!/usr/bin/python

import math
def FindClosestPointAboveXAxis(PointList,TargetPoint):
"""Given a list of points and a target point,this function
returns
the list's closest point, and its distance from the
target. It ignores all points with a negative y-coordinate. We
represent points in the plane (or on screen) as a two-valued
tuple of the form (x-coordinate,y-coordinate).***
   ClosestPoint=None
   for Point in PointList:
    if (Point[1]<0):
      continue
   DistPoint=math.sqrt((TargerPoint[0]-Point[0])**2 +
                        (TargetPoint[1]-Point[1])**2)
      if (ClosestDistance == None or
          DistPoint < ClosestDistance):
          ClosestPoint=Point
          ClosestDistance = DistanceToPoint
      if (DistanceToPoint==0):
      print "Point found in the list"
      break
   else:
      print "Point not found on the list"
   return  (ClosestPoint, ClosestDistance)


this is what i get when running it in a terminal
Code:
bash-2.05b$ ./ClosestPoint.py
  File "./ClosestPoint.py", line 28
   
    ^
SyntaxError: invalid token


thanx :P
i know its an easy question , and i feel retarded but , i want to learn ... this is a script from Python 2.1 bible ClosestPoint.py
Back to top
View user's profile Send private message
BigRedDot
n00b
n00b


Joined: 29 Oct 2002
Posts: 67
Location: Austin

PostPosted: Sun Jan 12, 2003 5:52 am    Post subject: Reply with quote

Code:
tuple of the form (x-coordinate,y-coordinate).***


Try closing the comment with triple quotes instead of triple asterisks.
_________________
Even if you are one-in-a-million, there are still 6000 people just like you.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum