Why is Python reporting that the variable `perimeter` is undefined?

```
#The first function will accept the length and width of a rectangle as its two parameters and return the rectangles perimeter
length=float(input("What is the length of your rectangle?"))
width=float(input("What is the width of your rectangle?"))
def rectanglePerimeter(length,width): #the parameter limits , it will accept the length and the width 
    perimeter= (2*length) + (2*width ) #here we implement the equation for the rectangles perimeter 
    return perimeter #return the result 
def rectangleArea(length,width):
    area= length*width 
    return area 
if perimeter> area:
    print ("the perimeter is larger than the area")
elif perimeter<area:
    print ("the area is larger than the perimeter")
    if perimeter == area:
        print ("the area and the perimeter are equal") 

```