Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Looking for a Python code for below program using decision making --------------

ID: 3909757 • Letter: L

Question

Looking for a Python code for below program using decision making

------------------------------------------------------

The Gocargo carriers have got 4 dry storage containers each of different capacities.

Reagan, the prime customer of Gocargo, needs its timely service. Since Gocargo is a busy shipping industry, it issues token numbers to all the incoming cargos. Please help the logistics team to find in which container Reagan's cargo can be packed in, using the capacities of the containers and the token number. Given the capacity of each container, and the customer’s cargo's number, write a program to find the container number in which the cargo is going to be placed.

Print "Not Possible", if the commodity cannot be packed in any of the containers.

Note: The Cargo numbers and token numbers both starts from 0.

Input Format :
            Input consists of 5 integers, where the first four integers corresponds to the capacity of the 4 dry storage containers respectively, i.e., number of cargos that can be placed in each of the containers and the 5th integer is Reagan's cargo number that is to be shipped.

Output Format :
            Output can either be an integer, the container number, or a string, “Not Possible” when the cargo cannot be shipped.
Please refer to sample output for formatting details.

Sample Input 1:
40
50
50
20
120
Sample Output 1:
3

Sample Input 2:
40
50
50
20
180
Sample Output 2:
Not Possible

Explanation for sample 1:
According to the sample input 1, each container has different cargo capacities. 40 is the cargo capacity of container 1, 50 is the cargo capacity of container 2, 50 is the cargo capacity of container 3, 20 is the cargo capacity of container 4.
If customer's cargo number is 120, then already 120 cargos are filled in the containers since the cargo number starts from 0. 0-39 cargos are in container 1; 40-89 cargos in the second container; 90-119 cargos in the third container. Still third container is not full. Therefore the 120th cargo will be filled in 3rd container.

Explanation for sample 2:
According to the sample input 2, each container has different cargo capacities. 40 is the cargo capacity of container 1, 50 is the cargo capacity of container 2, 50 is the cargo capacity of container 3, 20 is the cargo capacity of container 4.
If customer's cargo's number is 180, 0-39 cargos are in container 1; 40-89 cargos in the second container; 90-139 cargos in the third container; 140-159 cargos in the fourth container. All the containers are full. Therefore it is Not Possible to fill the 180th container in the container.

--------------------------------------------------

Thanks

Explanation / Answer

Here is the working python code:

size_of_cargo1 = input() #take size of cargo number 1 as input from user
size_of_cargo2 = input() #take size of cargo number 2 as input from user
size_of_cargo3 = input() #take size of cargo number 3 as input from user
size_of_cargo4 = input() #take size of cargo number 4 as input from user
Raegan_cargo = input()

#if size of all the cargos is less than the Raegan cargo number, it means the Raegan container will not be filled in any container
if(size_of_cargo1+size_of_cargo2+size_of_cargo3+size_of_cargo4<=Raegan_cargo):
    print "Not Possible "
else:
    #if raegan cargo number is between 0 to (size_of_cargo1-1),
    if(Raegan_cargo-size_of_cargo1<0):
        print "1"
    #if raegan cargo number is between size_of_cargo1 to (size_of_cargo2-1),
    elif (Raegan_cargo-size_of_cargo1-size_of_cargo2<0):
        print "2"
    #if raegan cargo number is between size_of_cargo2 to (size_of_cargo3-1),
    elif (Raegan_cargo-size_of_cargo1-size_of_cargo2-size_of_cargo3<0):
        print "3"
    #if raegan cargo number is between size_of_cargo3 to (size_of_cargo4-1),
    else:
        print "4"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote