On 2/21/2012 6:51 PM, William Stewart wrote:
hello
I need to rewrite area.py program so that it has separate functions
for the perimeter and area of a square, a rectangle, and a circle
(3.14 * radius**2).
"Need to"" - why? Is this a homework assignment?
I am horrible at math and I cannot even figure out what I need to do
for this
Any help would be appreciated
All I have is the menu which looks like this
Did you run this program? What results did you get? How did they differ
from what you expected?
What does being "horrible at mat" have to do with this?
What do you know about defining functions?
Did you write this program yourself?
If you are taking a Python class and don't know what to do either the
class is poorly designed or you are in the wrong class.
Please say more about this.
We are glad to help, but won't write your homework for you.
import math
print "your options are:"
print " "
print "1) Area(SQUARE)"
print "2) Area(RECTANGLE)"
print "3) Area(CIRCLE)"
print "4) Perimeter(SQUARE)"
print "5) Perimeter(RECTANGLE)"
print "6) Perimeter(CIRCLE)"
print "7) Exit"
while True:
selection = raw_input("Please select an option from the menu.: ")
python area.py
print "Calculate information about a rectangle"
length = input("Length:")
width = input("Width:")
print "Area",length*width
print "Perimeter",2*length+2*width
print 'To find the area of a rectangle,'
print 'Enter the width and height below.'
print
w = input('Width: ')
while w <= 0:
print 'Must be a positive number'
w = input('Width: ')
h = input('Height: ')
while h <= 0:
print 'Must be a positive number'
h = input('Height: ')
print 'Width =',w,' Height =',h,' so Area =',area(w,h)
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
--
Bob Gailer
919-636-4239
Chapel Hill NC
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor