On 02/21/2012 06: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).
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
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)
Just what don't you understand? If it's really just the math, then go
ahead and write dummy versions of the needed functions and control
structures, and then ask for help modifying the code.
There are bugs in the present code that have nothing to do with math,
and I'm not just referring to the line "python area.py".
--
DaveA
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor