V
V
VanD2020-12-10 21:06:32
IT education
VanD, 2020-12-10 21:06:32

How to add python code?

I was making code and I had an idea, but I don't know how to implement it. Having a rectangle on the coordinate plane, whose one corner is at the origin, and the opposite, lying on the same diagonal, is given by the coordinates (x, y). Write a program that, given the coordinates of a point (x, y), determines whether a point belongs to this rectangle. Is it possible to somehow implement this. (I made code that works with shapes)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AVKor, 2020-12-10
@AVKor

The problem has no solution, since the rectangle is not uniquely determined by the indicated two points.

P
PavelMos, 2020-12-10
@PavelMos

in python there is an expression "in range" which returns true/false. Left border - including, right border - not including.

a=1
a in range (1,20)
Out[5]: True
a=20
a in range (1,20)
Out[8]: False

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question