Can someone please give me feedback on this code for the rectangle exercise. It works but do you think it can be optimised further or is it good? Would you code it any differently? @sgiri
#Rectangle x_y coordinates left_top_x, left_top_y and right_bottom_x, right_bottom_y
def insiderectangletest():
print("This program tests if your spot is inside your rectangle.")
try:
left_top_x = float(input("Enter numeric x coordinate for top left corner of rectangle: "))
left_top_y = float(input("Enter numeric y coordinate for top left corner of rectangle: "))
right_bottom_x = float(input("Enter numeric x coordinate for bottom right corner of rectangle: "))
right_bottom_y = float(input("Enter numeric y coordinate for bottom right corner of rectangle: "))
spot_x = float(input("Enter numeric x coordinate for spot: "))
spot_y = float(input("Enter numeric x coordinate for spot: "))
if spot_x < right_bottom_x and spot_y < right_bottom_y and spot_x > left_top_x and spot_y > left_top_y:
print("Spot is inside rectangle")
else:
print("Spot is outside or on the border of the rectangle")
except:
print("Ensure all x and y coordinates are entered as numeric values.")
insiderectangletest()