Apr-24-2020, 04:52 PM
(This post was last modified: Apr-25-2020, 06:40 AM by deanhystad.)
You do not need a multi-dimensional array. You need to write a function that will tell you if x, y is part of a rectangle.
To do this you need a data structure that can store your rectangle. The code below saves rectangle information in a dictionary. You could also use a list or a tuple or a class:
A good next step is modifying your program so you can enter multiple rectangles and save them all in a list. Print out the list to verify the information was saved correctly.
To do this you need a data structure that can store your rectangle. The code below saves rectangle information in a dictionary. You could also use a list or a tuple or a class:
line = input('Input rectangle coordinates x1 y1 x2 y2 pixel:') v = line.split() rect = {'x1':v[0], 'y1':v[1], 'x2':v[2], 'x3':v[3], 'pixel':v[4]}You need to support having multiple rectangles, so you will have to store all the rectangles in a list.
A good next step is modifying your program so you can enter multiple rectangles and save them all in a list. Print out the list to verify the information was saved correctly.