Python Program to calculates area and perimeter of a rectangle


Example

									
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# function definitions
def area(b, h):
 """ calculate area of a rectangle"""
 A = b * h
 return A
def perimeter(b, h):
 """ calulates perimeter of a rectangle"""
 P = 2 * (b+h)
 return P
# main program using defined functions
width = 5
height = 3
print ("Area = ", area(width, height))
print ("Perimeter = ", perimeter(width, height))


Output

Area =  15
Perimeter =  16


Explanation

The arguments are the values passed to the function. the return value is the value that the function gives back to the calling program statement.