#!/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))
Area = 15 Perimeter = 16
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.