[Tutor] how to rewrite area.py
williamjstewart at rogers.com
Wed Feb 22 17:00:00 CET 2012
On 2/21/2012 6:51 PM, William Stewart wrote:
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?
Yes it wont run tdue to some problems in my indents but I am working on it
What does being "horrible at mat" have to do with this?
I dont know
What do you know about defining functions? Not much
Did you write this program yourself?
this is new to me it a beginners computer class, but I think this may be too advanced for me , I havent learned anything about python before starting except some basic tutorials
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.
Someone game me some help but Im not sure if I piut it in right
it looks like this
from math import pi
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"
selection = raw_input("Please select an option from the menu.: ")
print "Please enter the width of a square"
area = width**2
Print "please enter the width of a rectangle"
area = width*height
print "please enter the radius of a circle"
radius = pi**2
area = width*width = width**2
perimeter = width+width+width+width = 4*width
area = width*height
perimeter = width+height+width+height = 2*(width+height)
area = pi*radius**2
circumference = 2*pi*radius
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor