#OBJECTIVE: THIS PROGRAM DISPLAYS MY UNDERSTANDING OF FUNCTIONS #THROUGH DEVOLOPMENT OF A PROGRAM CALLED ANIMAL PENS #CREATED BY: HILL, DARNELL #DATE: FEBURARY 11, 2014 #COURSE: CIS 229 PYHTON #GLOBAL VARIABLES: global area global perimenter import math def main(): print'''WELCOME TO ANIMAL PENS\nLETS GET STARTED\n''' getCow() getRhino() getTurtle() getBird() print("\nTHE TOTAL AREA IS: %.3f\nTHE TOTAL PERIMENTER IS: %.3f") % (area, perimenter) def getCow(): cowLength = input("ENTER THE COW'S LENGTH: ") cowHeight = input("\nENTER THE COW'S HEIGHT: ") cowArea = cowLength * cowHeight cowPerimenter = (2 * cowLength) + (2 * cowHeight) global area area = cowArea global perimenter perimenter = cowPerimenter print("\nTHE AREA FOR THE COW: %d\nTHE PERIMENTER FOR THE COW: %d") % (cowArea, cowPerimenter) return def getRhino(): rhinoLength = input("\nENTER THE RHINO'S LENGTH: ") rhinoHeight = input("\nENTER THE RHINO'S HEIGHT: ") rhinoArea = rhinoLength * rhinoHeight rhinoPerimenter = (2 * rhinoLength) + (2 * rhinoHeight) global area area = area + rhinoArea global perimenter perimenter = perimenter + rhinoPerimenter print("\nTHE AREA FOR THE RHINO: %d\nTHE PERIMENTER FOR THE RHINO: %d") % (rhinoArea, rhinoPerimenter) return def getTurtle(): turtleLength = input("\nENTER THE TURTLE'S LENGTH: ") turtleHeight = input("\nENTER THE TURTLE'S HEIGHT: ") turtleArea = turtleLength * turtleHeight turtlePerimenter = (turtleLength * 2) + (turtleHeight * 2) global area area = area + turtleArea global perimenter perimenter = perimenter + turtlePerimenter print("\nTHE AREA FOR THE TURTLE: %d\nTHE PERIMENTER FOR THE TURTLE: %d") % (turtleArea, turtlePerimenter) return def getBird(): birdLenght = input("\nENTER THE BIRD'S LENGTH: ") birdHeight = input("\nENTER THE BIRD'S HEIGHT: ") birdRadius = input("\nENTER THE BIRD'S RADIUS: ") birdPerimenter = 2 * math.pi * birdRadius birdArea = (math.pi) * (birdRadius ** 2) global area area = area + birdArea global perimenter perimenter = perimenter + birdPerimenter print("\nTHE AREA FOR THE BIRD: %.2f\nTHE PERIMENTER FOR THE BIRD: %.2f") % (birdArea, birdPerimenter) return main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question