Python Program
Shipping Charges
The Fast Freight Shipping Company charges the following rates:
Weight of Package Rate per Pound
2 pounds or less $1.10
Over 2 pounds but not more than 6 pounds $2.20
Over 6 pounds but not more than 10 pounds $3.70
Over 10 pounds but not more than 20 pounds $4.50
Over 20 pounds package cannot be shipped
Write a program that generates a random number (between 1 and 50 inclusive) that represents the weight of a package. The program should then display the weight of a package , the rate per Pound, and the shipping cost. If the package weight is more than 20, display the package weight and a message that the package is over 20 pounds and cannot be shipped.
Sample output:
Package weight: 5
Shipping rate: $ 2.2
Shipping charge: $ 11.0
import random
for i in range (3):
r = random.randint(1, 50)
print("Package weight: ", r)
if r <= 2 :
print("Shipping rate: $ 1.10")
print("Shipping charge: $", r * 1.10)
elif 2 < r <= 6 :
print("Shipping rate: $ 2.20")
print("Shipping charge: $", r * 2.20)
elif 6 < r <= 10 :
print("Shipping rate: $ 3.70")
print("Shipping charge: $", r * 3.70)
elif 10 < r <=20 :
print("Shipping rate: $4.50")
print("Shipping charge: $", r * 4.50)
elif r > 20 :
print("The package is over 20 pounds and cannot be shipped")
print()
All Rights Reserved by Jahirul Opi