Hello everyone. I am in a programming fundamentals class which we are using python. I am working on a Lab problem and really am not 100% sure how to do it.
A shipping company (Fast Freight Shipping Company) wants a program that asks the user to enter the weight of a package and then display the shipping charges. (This was the easy part)
2 pounds or less = $1.10
over 2 but not more than 6 pounds = $2.20
over 6 but not more than 10 pounds = $3.70
over 10 = 3.80
My teacher added on to this saying we need to
Next, you will enhance this lab to include the following:
a. Include the name of the shipper and recipient.
b. Print a properly formatted invoice.
c. The shipper is required to purchase insurance on their package. The insurance
rates are based on the value of the contents of the package and are as follows:
Package Value Rate
0 – 500 3.99
501 – 2000 5.99
2. The printed invoice must include the name of the shipper and recipient. As well, this
invoice will display the total of the shipping charge and the insurance cost.
So here is my code
def main(): #define shipping rates less_two = 1.10 twoPlus_six = 2.20 sixPlus_ten = 3.70 tenPlus = 3.80 shippingClass = 0 insuranceClass = 0 insurance1 = 3.99 insurance2 = 5.99 insurance3 = 10.99 #Getting name of shipper and recipient company = str(input('Please enter the name of the shipping company: ')) customer = str(input('Please enter the name of the customer :')) #get weight of the package weight = float(input('Enter the weight of the package: ')) insurance = shippingRate(weight, shippingClass) #shipping classification if weight <= 2.0: shippingClass = less_two elif weight > 2.0 and weight <= 6.0: shippingClass = twoPlus_six elif weight > 6.0 and weight <= 10.0: shippingClass = sixPlus_ten elif weight > 10.0: shippingClass = tenPlus else: print('Weight has to be a possitive number') print() if insurance <= 500 and insurance >= 0: insuranceClass = insurance1 elif insurance > 500 and insurance <= 2000: insuranceClass = insurance2 else: insuranceClass = insurance3 total = shippingRate + insuranceClass #New variables insurance = shippingRate(weight, shippingClass) shippingRate(weight, shippingClass) #Display print('The total with insurance will be $', total, '.', sep='') print() int(input('Press ENTER to end')) #calculating shipping cost. def shippingRate(poundage, classification): shipping_rate = poundage * classification print('The shipping will cost $', format(shipping_rate, '.2f'), '.', sep='') main()
I am getting this error
Traceback (most recent call last): File "F:\Python\ACC - Labs\Lab 3\lab3_shipping.py", line 50, in <module> main() File "F:\Python\ACC - Labs\Lab 3\lab3_shipping.py", line 31, in main if insurance <= 500 and insurance >= 0: TypeError: unorderable types: NoneType() <= int()
I'm sure you can see that I do not have a complete understanding of what I am doing yet so any help or direction would be great. Also I am sorry for the sloppy code. I did the first part and now trying to do the 2nd and it is just a mess right now. After I figure it out I was going to clean it up.
Thank you for anyone who spends time to help me.
Edited 4 Years Ago by nUmbdA: edit