Answer the question
In order to leave comments, you need to log in
How to compare a number in python so that the result is always true/false?
I'm solving an Olympiad problem in programming. Given a set of points. You need to calculate the area of the largest possible quadrilateral.
First, I formed a list of points [(x1,y1), (x2,y2), (xn,yn)] and then worked with them. But then I realized that it is not really needed and you can find the points I need in the first cycle, where I read the initial data. In addition, the maximum number of points can be obtained without using arrays (after consultation, it was decided that a list could be used to store the coordinates of the vertices of the quadrilateral).
I used to do this:
top = points[0]
for point in points:
if (point[0] == 0) and (point[1] > top[1]): top = [0,point[1]]
top = [*что-то*, *что-то*]
for ... :
if (point[0] == 0) and (point[1] > top[1]): top = [0,point[1]]
Answer the question
In order to leave comments, you need to log in
As far as I know in Python 2.x the constant None
is always less than any number
print None < 1024 #True
print None < 0 #True
print None < -1024 #True
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question