Finding the area of a rectangle in python Q: Standard input consists of exactly four integers, first x1 and y1, the coordinates of the bottom-left corner of a rectangle, then x2 and y2, the coordinates of the top-right corner.
Write a Python script named area-of-rectangle.py which outputs the rectangle’s area.
I'm SO stuck and have no clue what I'm doing. I wrote this
x1 = int(input())
y1 = int(input())
x2 = int(input())
y2 = int(input())
bottom_left = (x1 + y1)
top_right = (x2 + y2)
area = bottom_left * top_right
print(area)
IT'S ALWAYS WRONG. Please help :(
To calculate the area of a rectangle on a coordinate system, you need the length between x1 and x2, and the length between y1 and y2.
x1 = int(input())
y1 = int(input())
x2 = int(input())
y2 = int(input())

xDiff = abs(x1 - x2) # Using absolute value to ignore negatives
yDiff = abs(y1 - y2)

area = xDiff * yDiff

Edit: Forgot to mention, if x2 is always greater than x1, and y2 is always greater than y1, instead you can just use xDiff = x2 - x1 and yDiff = y2 - y1