Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Volumetric Weight Calculation to Improve Shipping Cost Accuracy #3651

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Shipping_Cost_Calculator.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# Shipping Cost Calculator

## Input package weight and shipping rate
## Input package weight, volume dimensions, and shipping rate
weight = float(input("Enter the package weight in kilograms: "))
length = float(input("Enter the package length in centimeters: "))
width = float(input("Enter the package width in centimeters: "))
height = float(input("Enter the package height in centimeters: "))
rate = float(input("Enter the shipping rate per kilogram: "))

## Calculate volumetric weight
volumetric_weight = (length * width * height) / 5000

## Choose the greater between actual and volumetric weight
chargeable_weight = max(weight, volumetric_weight)

## Calculate shipping cost
shipping_cost = weight * rate
shipping_cost = chargeable_weight * rate

## Display the result
print(f"Shipping Cost: {shipping_cost} USD")

print(f"Shipping Cost: {shipping_cost:.2f} USD (based on {chargeable_weight:.2f} kg)")
Loading