[Tutor] how to rewrite area.py

William Stewart 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
import math
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"
while True: 
    selection = raw_input("Please select an option from the menu.: ")

def get_area_of_square():
    print "Please enter the width of a square"
    area = width**2
    return area

def get_area_of_rectangle():
    Print "please enter the width of a rectangle"
    area = width*height
    return area
def get_radius_of_circle():
    print "please enter the radius of a circle"
    radius = pi**2
    retrun radius
    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...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120222/5c6a36b2/attachment-0001.html>

More information about the Tutor mailing list