Answer to Question #246790 in Python for saksham

Question #246790
IF/ELSE Control flow in Python to work out price of courier service from 4 choices
You need to design a program for a courier company to calculate the cost of sending a parcel.
Ask the user to enter the price of the package they would like to purchase.
Ask the user to enter the total distance of the delivery in kilometers.
Now, add on the delivery costs to get the final cost of the product. There are four categories to factor in when determining a parcel’s final cost, each with two options based on the customer’s delivery preferences. (Use an if else statement based on the choice they make)
Delivery via air ($0.36 per km) or via freight ($0.25 per km)
Full insurance ($50.00) or limited insurance ($25.00)
Gift option ($15.00) or not ($0.00)
Priority delivery ($100.00) or standard delivery ($20.00)
Write code to work out the total cost of the package based on the options selected in each category.

Can anyone help?
1
Expert's answer
2021-10-05T23:14:04-0400

Source Code


price_of_package=int(input("Enter the price of the package you would like to purchase: "))
total_distance=int(input("Enter the total distance of the delivery in kilometers: "))


print("Choose shipping preference:\n1. Air \n2. Freight")
c=int(input())


cost_per_distance = 0
if (c==1):
    cost_per_distance = 0.36
elif (c==2):
    cost_per_distance = 0.25
 
print("Choose type of insurance:\n1. Full insurance \n2. limited insurance")
c2=int(input()) 


insurance_cost = 0
if(c2==1):
    insurance_cost = 50
elif(c2==2):
    insurance_cost = 25
    
print("Add gift?:\n1. Yes \n2. No")
c3=int(input()) 


gift_cost = 0
if(c3==1):
    gift_cost = 15
elif(c3==2):
    gift_cost = 0
    
    
print("Choose type of delivery:\n1. Priority delivery \n2. Standard delivery")
c4=int(input()) 


type_delivery_cost=0
if(c4==1):
    type_delivery_cost = 100
elif(c4==2):
    type_delivery_cost = 20


total_cost = price_of_package + total_distance*cost_per_distance + insurance_cost + gift_cost + type_delivery_cost


print("Total Cost: ",total_cost)
    
    


Sample Output






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS