#------------------------------------------------------------------------------ # Rectangle2.py # Uses functions #------------------------------------------------------------------------------ def rectangle_area(x, y): """Returns the area of a rectangle""" a = x*y return a # end rectangle_area() def rectangle_perimeter(x, y): """Returns the perimeter of a rectangle""" p = 2*x + 2*y return p # end rectangle_perimeter() # main() ---------------------------------------------------------------------- def main(): print("Enter the length and width of a rectangle: ") length = float(input("length: ")) width = float(input("width: ")) print() print("The area is", rectangle_area(length, width)) print("The perimeter is", rectangle_perimeter(length, width)) print() print("Enter the length and width of another rectangle: ") length = float(input("length: ")) width = float(input("width: ")) print() print("The area is", rectangle_area(length, width)) print("The perimeter is", rectangle_perimeter(length, width)) print() # end main() ------------------------------------------------------------------ # ----------------------------------------------------------------------------- if __name__=='__main__': main() # end if ----------------------------------------------------------------------