Public feed #726318

mypydev

public text v1 · immutable
Raw Edit
·published 2007-10-05 02:11 UTC
rendered paste body

def instructions():
    print "This Program allows one to calculate the cost of producing an open top cylinder. "


def userinput ():
    
    d = float( raw_input( "Cylinder the diameter of the base of the cyclinder(cm): " ).strip() )
    h = float( raw_input( "Cylinder height (cm): " ).strip() )
    p = float( raw_input( "Price per (cm^2): ").strip() )
    a = float( raw_input( "Number of units: ").strip() )
    return d, h, p, a

def surfacearea(r, h):
    import math
    SA =  (math.pi * r  * r ) +  (2 * math.pi * r * h )
    return SA

def output(SA, p, a):
    unitprice = SA * p
    order = unitprice * a
    return unitprice, order


instructions()    
d, h, p, a = userinput()
r = d / 2 
sa = surfacearea (r,h)
print (" The cylinder has a surface area of %.2f cm^2 and a cost of %.2f to produce %f units") % output(sa, p, a)