Sample script for calculating shipping cost?

I would like to integrate UPS or USPS for shipping. Does anyone have a sample script that calculates shipping cost based on weight?

I see now that by including the weight of my product, it works properly. Never mind!