Question

Python coding

The Weight Detection Sensor

The Gocargo carriers has planned to automate the filling of cargos in the container. They have installed a weight detection sensor in the conveyor belt where cargos will be taken to the container. The sensor needs to be programmed in a way that it stops the conveyor sending the cargos, when the maximum capacity of the container is reached or exceeded.


Please write a code to enable the sensor to automate this task of finding the number of cargos that can be accommodated in the container.


Input Format :

      Input consists of integers, where the first line corresponds to the maximum weight of the container in tonnes.

      The next lines corresponds to the weight of the cargos in tonnes.


Note: Get the inputs till the maximum weight is reached.


Output Format :

Output consists of an integer which corresponds to the number of cargos that can be accommodated in the container.

Refer to sample input and output for formatting specifications.


Sample Input:

100

25

35

30

40

Sample Output:

3


Explanation for sample:

Total weight of the container = 100.

Weight of 1st cargo = 25. Remaining weight = 75.

Weight of 2nd cargo = 35. Remaining weight = 40.

Weight of 3rd cargo = 30. Remaining weight = 10.

Weight of 4th cargo = 40. 4th cargo cannot be accomodated in the container.

Therefore, total cargos accomodated = 3.


0 0
Add a comment Improve this question Transcribed image text
Answer #1


max_weigth=int(input())

sum=0


list=[]


for i in range(0,4,1):

    list.append(input())


count=0




for i in range(0,len(list),1):


 sum+=int(list[i])




 if(max_weigth>=sum):


  count+=1




 elif max_weigth<sum:


  break




print(count)


answered by: Satyam Keshri
Add a comment
Know the answer?
Add Answer to:
Python coding
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Coding

    The Cargo arrangementThe Gocargo carriers have a pattern of arranging the cargos in the container. Given the length of edge of the container, print the cargo arrangement pattern in the container as shown in the sample IO. The base of the container is always a square.Note: The Cargo are of unit length.Input format :     The input is an integer that corresponds to the side length of the container.Output Format:     Output is the cargo arrangement pattern inside the container.Please refer to the sample...

  • Python coding

    The Gocargo are automating their testing works of the logistics wing too. They have planned to test if the container loading works correctly or not.Given the process involved in loading, in the form of expression, evaluate if the container loader has worked correct or not.Conventions'{' for cargos, '[' for containers and '(' for boxes.Rules:* cargo cannot be inside another cargo or container or box.* container cannot be inside another container or box.* box can be inside another box.Please check whether...

  • Python coding

    Palindromic CargoThe Gocargo carriers are celebrating their digitization process, which has given them a lot of benefits and ease of work for their employees. In account of this initiative they are offering their customers to ship their cargoes free of cost, if and only if the cargo names are palindromic.Given a cargo name, check whether the cargo name is a palindrome or not. Consider only alphabets while checking, remove special characters and spaces.Note : Define a function named check Palindrome()...

  • Solve by using Python language Validation of Invoice Number The Gocargo carriers are extending their automation...

    Solve by using Python language Validation of Invoice Number The Gocargo carriers are extending their automation to their accounts wing too, It is difficult to identify the source and destination of a cargo in an invoice. So given an invoice number, determine the "from" and "to" for a cargo. The format of invoice number is as follows: * from-Country and to-Country are separated by few digits(atleast 1) * after to-Country there are few digits. Input Format :       Input consists...

  • Python Problem, just need some guidance with the description, pseudocode and run time. I believe this...

    Python Problem, just need some guidance with the description, pseudocode and run time. I believe this is an 0-1 knapsack problem? Shopping Spree: (20 points) Acme Super Store is having a contest to give away shopping sprees to lucky families. If a family wins a shopping spree each person in the family can take any items in the store that he or she can carry out, however each person can only take one of each type of item. For example,...

  • Declare and initialize 4 Constants for the course category weights: The weight of Homework will be...

    Declare and initialize 4 Constants for the course category weights: The weight of Homework will be 15% The weight of Tests will be 35% The weight of the Mid term will be 20% The weight of the Fin al will be 30% Remember to name your Constants according to Java standards. Declare a variable to store the input for the number of homework scores and use a Scanner method to read the value from the Console. Declare two variables: one...

  • In Python Question 3 (13 points): Purpose: To practice your ability to modify lists and compute...

    In Python Question 3 (13 points): Purpose: To practice your ability to modify lists and compute with lists of lists Degree of Difficulty: Moderate For this question, you are given some population estimates, by age group, from Statistics Canada for some provinces. Starter File a5q3 starter.py is a file that contains a list of lists, to which the variable Pop-data refers, which represents 2020 population numbers. The first item in Pop_data is a list whose first item is the string...

  • scheduling program in C, please help 1 Objectives This programming project is to simulate a few...

    scheduling program in C, please help 1 Objectives This programming project is to simulate a few CPU scheduling policies discussed in the class. You will write a C program to implement a simulator with different scheduling algorithms. The simulator selects a task to run from ready queue based on the scheduling algorithm. Since the project intends to simulate a CPU scheduler, so it does not require any actual process creation or execution. When a task is scheduled, the simulator will...

  • Write a C program for: One technique for dealing with deadlock is called “detect and recover.” In...

    Write a C program for: One technique for dealing with deadlock is called “detect and recover.” In this scheme, some procedure is used to identify when a deadlock occurs, and then another procedure is used to deal with the blocked processes. One technique to identify a deadlock is to maintain a resource graph that identifies all processes, all resources, and the relationships between them (that is, which processes exclusively own which resources, and which processes are blocked waiting for which...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT