Area

In this problem, you will be given a square which has a length of n. Co-ordinates of the square are (0,0), (n,0),(n,n),(0,n) . You need to draw 4 straight lines:


This is a companion discussion topic for the original entry at https://toph.co/p/area

Why my program is producing wrong answers in test case 4. plzz hlp

def area(x):
    return x*2 - 4


b = int(input())
for i in range(b):
    c = float(input())
    print(f'Case {i + 1}: {area(c)}')

here c would be an integer number. Not a float type number.

How did you get the formula 2x-4?

here total area=nn…
the area of 4 triangle=4{(n-2)n/21/2}
=n
n-2n
the area of small square=4(1)
=4
now-the required area=(nn) -{(nn-2n)+4}
=2n-4(ans)