Started Rectangle Project
This commit is contained in:
commit
26e1253c0d
39 changed files with 544 additions and 0 deletions
40
homework06/functions/functions04.py
Normal file
40
homework06/functions/functions04.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# Simple function examples
|
||||
|
||||
def rectanglePerimeter(rLength,rWidth):
|
||||
'''
|
||||
rLength: length of the rectangle.
|
||||
|
||||
rWidth: width of the rectangle.
|
||||
|
||||
Returns the perimeter of the rectangle.'''
|
||||
perimeter = 2 * (rLength + rWidth)
|
||||
return(perimeter)
|
||||
|
||||
def rectangleArea(rLength,rWidth):
|
||||
area = rLength * rWidth
|
||||
return(area)
|
||||
|
||||
def squarePerimeter(rLength):
|
||||
perimeter = rectanglePerimeter(rLength,rLength)
|
||||
return(perimeter)
|
||||
|
||||
def squareArea(rLength):
|
||||
area = rectangleArea(rLength,rLength)
|
||||
return(area)
|
||||
|
||||
# ======================== Main Program =============================
|
||||
|
||||
length = 2.
|
||||
width = 3.
|
||||
|
||||
retValue = rectanglePerimeter(length,width)
|
||||
print(retValue)
|
||||
|
||||
retValue = rectangleArea(length,width)
|
||||
print(retValue)
|
||||
|
||||
retValue = squarePerimeter(length)
|
||||
print(retValue)
|
||||
|
||||
retValue = squareArea(length)
|
||||
print(retValue)
|
||||
Loading…
Add table
Add a link
Reference in a new issue