Shipping Container Optimization Project

Shipping Container Optimization Project

 

You work in a shipping company and you are responsible for the containers optimization. Your task is to load contaniers with the maximum number of packages so that the company doesn’t waste space. To do so, you decide to build a simple program using Python to automate these tasks.

Given a 2D container of length X and height Y to ship packages of standard length x and height y. Assume all sizes are integers.

Write a Python program that request the manager to enter the container and packages sizes and calculates how many packages can be sent in the container. Given X, Y, x, and y, determine how many packages can fit into a single container so that they can be shipped to their destination.

Steps

  1. Take Input:
    • Prompt the user to enter the values of X (container width), Y (container height), x (box width), and y (box height).
  2. Calculate length and height :
    • Calculate how many packages can fit along the x-axis and y-axis within the container.
  3. Compute Total Packages:
    • Multiply the number of boxes that can fit along the x-axis by the number of boxes that can fit along the y-axis to get the total number of packages that can fit in the container.
  4. Display Result:
    • Output the total number of packages that can fit in the container.

Expected output

Enter the container width in centimeters (X): 300
Enter the container height in centimeters (Y): 200
Enter the box width in centimeters (x): 50
Enter the box height in centimeters (y): 30
The total number of packages that can fit in the container is: 36

Solution


# Step 1: Take Input
X = int(input("Enter the container width (X): "))
Y = int(input("Enter the container height (Y): "))
x = int(input("Enter the box width (x): "))
y = int(input("Enter the box height (y): "))

# Step 2: Calculate Rows and Columns
columns = X // x  # Number of boxes that can fit along the x-axis
rows = Y // y     # Number of boxes that can fit along the y-axis

# Step 3: Compute Total Packages
total_packages = columns * rows  # Total number of packages that can fit in the container

# Step 4: Display Result
print(f"The total number of packages that can fit in the container is: {total_packages}")

We will be happy to hear your thoughts

Leave a reply

Python and Excel Projects for Practice
Register New Account
Shopping cart