You are given the `length` and `width` of a 4-sided polygon. The polygon can either be a rectangle or a square. 
If it is a square, return its area. If it is a rectangle, return its perimeter.

```
area_or_perimeter(6, 10) --> 32
area_or_perimeter(4, 4) --> 16
```

> Note: for the purposes of this kata you will assume that it is a square if its `length` and `width` are equal, otherwise it is a rectangle.

Difficulty: introductory

Starter code:

def area_or_perimeter(l , w):
	

Solutions:
def area_or_perimeter(l, w):
    return l * w if l == w else (l + w) * 2

area_or_perimeter = lambda a, b : a * b if a == b else 2 * (a + b)

def area_or_perimeter(l , w):
    return l * w if l == w else 2 * (l + w)

def area_or_perimeter(l , w):
    return l*w if l==w else l+l+w+w

def area_or_perimeter(l , w):
    return [(l+w)*2, l*w][(l == w)]

def area_or_perimeter(l , w):
    return l * l if l == w else 2 * (l + w)

def area_or_perimeter(l , w):
    if l == w:
        tot = l * w
    else:
        tot = l * 2 + w * 2
    return tot


def area_or_perimeter(l , w):
    return [l*w , 2*(l + w)][l != w]

area_or_perimeter=lambda l,w:(l==w)*l**2or(l+w)*2

def area_or_perimeter(l , w):
    resu = 0
    if l == w:
        resu = l*w
        return resu
    else:
        resu = 2*(l+w)
        return resu
        


def area_or_perimeter(l: int, w: int) -> int:
    """ Get the area of a square or the perimeter of a rectangle. """
    return l * w if l == w else l * 2 + w * 2

def area_or_perimeter(l , w):
    return l * l if l == w else l + l + w + w

area_or_perimeter = lambda l, w: (l*2)+(w*2) if l != w else l*w

def area_or_perimeter(l , w):
    # return your answer
    if l == w:
        return l*w
    else:
        return 2 *l + 2 * w

area_or_perimeter=lambda l,w:[2*(l+w),l*w][l==w]

def area_or_perimeter(l , w):
    return (2*l+2*w, l**2)[l==w]

def area_or_perimeter(l , w):
    return 2 * l + 2 * w if l!= w else l * w

def area_or_perimeter(l , w):
    if l == w :
        return l * w  
    else:
        l != w
        return (l * 2) + (w * 2)

def area_or_perimeter(l , w):
    if l != w:
        return (l + w) * 2
    if l == w:
        return l * w

def area_or_perimeter(l , w):
    if l != w : 
        return 2 * (l + w)
    if l == w :
        return l * w   

def area_or_perimeter(l , w):
    if l == w:
        return w * l
    else:
        return 2 * (w + l)

def area_or_perimeter(l , w):
    
    return l ** 2 if l == w else l + l + w + w 

def area_or_perimeter(l , w):
    if l == w:
        res = l * w
    else:
        res = l + l + w + w
    return res

def area_or_perimeter(l , w):
    return 2*(l+w) if l != w else w**2 

def area_or_perimeter(l , w):
    if l==w:
        return l*w
    else:
        return (w+l)*2

area_or_perimeter = lambda l, w: l*w if (l==w) else l*2+w*2


def area_or_perimeter(l , w):
    return 2*l + 2*w if l != w else l**2

def area_or_perimeter(l , w):
    
# =============================================================================
#     This function is given the length and width of a 4-sided polygon. 
#     The polygon can either be a rectangle or a square. 
#     Note: 
#         for the purposes of this kata you will assume that it is a square 
#         if its length and width are equal, otherwise it is a rectangle.
#     
#     If it is a square, the function returns its area. If it is a rectangle, 
#     the function returns its perimeter.
#     
#     Examples:
#         area_or_perimeter(6, 10) --> 32
#         area_or_perimeter(4, 4) --> 16
# =============================================================================
    
    if l == w: # test for a square
        return (l*w)
    else:       
        return ((2*l)+(2*w))

area_or_perimeter = lambda l , w: l*w if l == w else 2*(l+w)

area_or_perimeter=lambda l,w:l*w if l==w else l+l+w+w

area_or_perimeter=lambda l,w:[l+w<<1,l*w][l==w]

def area_or_perimeter(l , w):
    if l == w:
        return l*w
    else:
        return (l+w)*2

print((area_or_perimeter(6,10)))
print((area_or_perimeter(4,4)))


def area_or_perimeter(l , w):
    if l == w: #check square or rectangle
        result = l**2 
        return int(result)
    else:
        result = 2 * ( l + w )
        return int(result)


def area_or_perimeter(l , w):
    if l == w:
        polygon = "square"
        return  l**2
    else:
        polygon = "rectangle"
        return l*2 + w*2

def area_or_perimeter(length: int, width: int) -> int:
    """ This function returns area for a square or perimeter for a rectangle. """
    if length == width:
        return length * width
    return (2 * length) + (2 * width)

def area_or_perimeter(l , w):
    if l != w:
        return 2 * (l + w)
    return l**2

def area_or_perimeter(l , w):
    if l!=w:
        return l*2+w*2
    if l==w:
        return l*w

def area_or_perimeter(l , w):
    return w**2 if w == l else 2*(l+w)

def area_or_perimeter(length, width):
    if length == width:
        return length * width
    else:
        return 2 * (length + width)


def area_or_perimeter(l,w):
    if l == w:
        area = l * w
        return (area)
    elif l!=w:
        perimeter = 2 * (l + w)
        return (perimeter)
    else:
        return 0

def area_or_perimeter(l , w):
    val = l*w if l == w else (2*l+2*w)
    return val

def area_or_perimeter(l , w):
    if l == w:
        return l * w
    else:
        x = l*2
        y = w*2
        z = x + y
        return z

def area_or_perimeter(l , w):
    if l != w:
        return 2*w+2*l
    return w*l

def area_or_perimeter(l , w):
    if w == l:
        return l * w
    else:
        return 2 * (w + l)


def area_or_perimeter(l , w):
    if l == w:
        return l * w # Area of a square
    else:
        return 2 * (l+w) # Perimeter of a rectangle

def area_or_perimeter(l , w):
    area_rectangle = l * w
    area_square = l * l
    perimeter_rectangle = 2 * (l + w)
    perimeter_square = 4 * l
    if l == w:
        return area_square
    else:
        return perimeter_rectangle

def area_or_perimeter(I , W):
    if I!=W:  
        return 2*I+2*W
    else: 
         return I*W


def area_or_perimeter(l , w):
    if l == w:
        return l**2
    else:
        perimetr = (l*2)+(w*2)
        return perimetr

def area_or_perimeter(l , w):
    if l == w:
        return l*w
    if l != w:
        x=2*l
        y=2*w
        return x+y

def area_or_perimeter(l , w):
    a =  lambda l,w: l*w if(l==w) else 2*l+2*w
    return a(l, w)

def area_or_perimeter(l , w):
    if l == w:
        k = l**2
    else:
        k = l*2 + w*2
    return(k)

def area_or_perimeter(l , w):
    square = l == w
    
    if square == True:
        return l * w
    else:
        return 2 * (l + w)
        
    
    # return your answer


def area_or_perimeter(l , w):
    import math
    return math.pow(l, 2) if l == w else int(2 * l + 2 * w)

import unittest


def area_or_perimeter(length, width):
    return length * width if length == width else 2 * length + 2 * width
    
    
class TestAreaOrPerimeter(unittest.TestCase):
    def test_area(self):
        self.assertEqual(area_or_perimeter(length=4, width=4), 16)

    def test_perimeter(self):
        self.assertEqual(area_or_perimeter(length=10, width=4), 28)


def area_or_perimeter(l , w):
    if l * w == l * l:
        return l * w
    else:
        return (l*2) + (w*2)

def area_or_perimeter(l , w):
    return w**2 if w == l else w*2 + l*2

def area_or_perimeter(l=0, w=0):
    if l == w:
        return l * w
    else:
        return 2 * l + 2 * w


def area_or_perimeter(l , w):
    print(l,w)
    if l == w:
        return 0.5*((l*4) * (w/2))
    else:
        return (l + w) * 2

def area_or_perimeter(l , w):
    square = (l*w)
    rectangle = 2*(l+w)
    if l == w:
        return square
    else:
        return rectangle

area_or_perimeter = lambda l,w: [2*l+2*w,l*w][l==w]

def area_or_perimeter(l , w):
    mo = l+w
    if l == w:
        return l*w
    else:
        return mo * 2

def area_or_perimeter(l , w):
    if l == w:
        return l * w
    elif l < w or l > w:
        return l * 2 + w * 2

def area_or_perimeter(le , wi):
    if le == wi:
      return le * wi
    else:
      return 2 * le + 2 * wi

def area_or_perimeter(l , w):
    '''determine if a shape is a square or a rectangle'''
    square = l * w
    if l == w:
        return square
    else:
        return l + l + w + w


def area_or_perimeter(l , w):
    if l != w:
        return (l * 2) + (w * 2)
    
    if l == w:
        return l ** 2
        
    # return your answer


def area_or_perimeter(l , w):
    if l == w :
        return w * w
    else :
        return w + w + l + l

def area_or_perimeter(l , w):
    rectangle_perimeter=2*(l+w)
    square_area=l*l
    if l==w:
        return square_area 
    else:
        return rectangle_perimeter 


def area_or_perimeter(l , w):
    if l == w:
        return l**2
    else:
        l2 = l*2
        r2 = w*2
        return l2+r2

def area_or_perimeter(l , w):
    if l == w:
        return l*w
    else:
        return 2*(l+w)
#pogchamp


area_or_perimeter = lambda l , w: (l + w) * 2 if l != w else l**2

from math import *

def area_or_perimeter(l , w):
    if l == w:
        area = l * w
        return area
    else:
        p = l+w+l+w
        return p

def area_or_perimeter(l , w):
    if l == w:
        result = l * w
    else:
        result = (l+w) * 2
    return result

def area_or_perimeter(length, width):
    return length * width if length == width else (length + width) * 2

def area_or_perimeter(l,w):

    s = l * w
    p = (l + w) * 2
    if l == w:
        return (s)
    else:
        return (p)




def area_or_perimeter(length, width):
    if length == width:
        return length * width
    else:
        return length * 2 + width * 2

def area_or_perimeter(l , w):
    l = int(l)   #need to specify it as a integer otherwise it concatanets it and treats it as a string
    w = int(w)
    
    if l == w:
        return l*w 
    else:
        return l+l+w+w

def area_or_perimeter(l,w):
    if l==w:
        a=l*w
        return a
    else:
        b=l+w
        p=2*b
        return p


def area_or_perimeter(l, w):
    return l*l if l==w else (l+w)*2
print((area_or_perimeter(4, 4)))
print((area_or_perimeter(6, 10)))
  


def area_or_perimeter(l , w):
    if l == w:
        return pow(l,2)
    else:
        return (l+w) *2

def area_or_perimeter(l, w):
    area = (l * w)
    perimeter = 2 * (l + w)
    if (l == w):
        return area
    else:
        return perimeter
    
#BDD
#Given length and width of a4-sided polygon
#Find the area or perimeter
#The polygon is a square or rectangle
#If it is a square then return its area
#If it is a rectangle then return its perimeter

#pseudocode 
#Funtion that takes in a parameter of l and w
#If square return Area
#If rectangle return Perimeter


def area_or_perimeter(l , w):
    if l==w:
        res=l*w
    else:
        res=2*l+2*w
    return res
    # return your answer


def area_or_perimeter(l , w):
    return l==w and l**2 or 2*(l+w)

def area_or_perimeter(l , w):
    if w == l:
        return l * w
    else:
        return (l * 2) + (w * 2)
     


def area_or_perimeter(l , w):
    # return your answer
    if l == w:
         return(l*w)
    else:
         return(l+w+l+w)
l=4
w=4
print(l+w)

def area_or_perimeter(l , w):
    if l == w:
        return l*w
    else:
        c = l*2
        b = w*2
        return c+b
        


def area_or_perimeter(l , w):
    if w == l:
        return l * w
    else:
        return (l+w)*2

def area_or_perimeter(l,
                      w):

    if (l == w):

        return l * w

    return 2 * (l + w)


def area_or_perimeter(l, w):
    if(l == w):
        print((w * l))
        return l * w
    else:
        print((2*l + 2*w))
        return 2*l + 2*w


def area_or_perimeter(l , w):
    if l == w :
        return(l * w)
    else:
        return((l+w)*2)
        
area_or_perimeter(4,4)

def area_or_perimeter(l , w):
    if l==w:
        answer=l*w
    elif l!=w:
        answer=l+l+w+w
    return answer

def area_or_perimeter(l , w):
    if l == w:
        res = l*w
    else:
        res = (l*2) + (w*2)
    return res

def area_or_perimeter(l, w):
    # return your answer
    if l==w:
        return (l*w)
    else:
        return (2*(l+w))
    
    def area_or_perimeter(l , w):
    # return your answer
        if l==w:
            return (l*w)
        else:
            return (2*(l+w))
    
    


def area_or_perimeter(l , w):
    length = l
    width = w
    if length == width:
        return length * width
    return (length + width) * 2

def area_or_perimeter(l , w):
    # return your answer
    perimeter = 2*l + 2*w
    area = l * w
    if l == w:
        return area
    else:
        return perimeter
    
    


def area_or_perimeter(l , w):
    # return your answer
    if l == w:
        area = l * w
        return area
    else:
        perimeter = l + l + w + w
        return perimeter
    
    return area_or_perimeter

def area_or_perimeter(l , w):
    ans = (2*l) + (2*w)
    if l == w:
        ans = l*w
    return ans

def area_or_perimeter(l, w):
    if l != w:
        return l*2 + w*2
    elif l == w:
        return l*w

def area_or_perimeter(l , w):
    if l == w:
        square = l*w
        return square
    else:
        rectangle = (l*2) + (w*2)
        return rectangle

def area_or_perimeter(l , w):
    if l==w:
        Square = l*w
        return Square
    else:
        Rectangle = (l+w)*2
        return Rectangle


def area_or_perimeter(l , w):
    if l == w:
        answer = l*w
    else:
        answer = 2*(l+w)
    return answer