Question: Python topics utilized in this project are: lists loops input output functions --------------------- Create a python script (file ending in .py) that performs the following

Python topics utilized in this project are:

  • lists
  • loops
  • input
  • output
  • functions

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

Create a python script (file ending in .py) that performs the following steps:

  • Name your file YourNameKnapsack.py.
  • Get input for values into a list until 'q' is entered. Store these into a list
  • pass those values in a list to a function to determine if they meet the following criteria:
    • Each value must be greater than the sum of all values before it.
    • Example: 1, 4, 6, 11, 28 is INVALID because 1, 4, 6 = 11 so the next value of 11 is not reater than the sum of the previous values.
    • Example: 1, 4, 6. 12. 28 is VALID.
  • Output results as shown in the example below.
  • You do not need to run this multiple times as shown in the example.

Sample:

Please enter a value for the knapsack (q to Quit): 1 Please enter a value for the knapsack (q to Quit): 4 Please enter a value for the knapsack (q to Quit): 6 Please enter a value for the knapsack (q to Quit): 11 Please enter a value for the knapsack (q to Quit): 28 Please enter a value for the knapsack (q to Quit): q Verifying Knapsack: 1, 4, 6, 11, 28 Knapsack has ISSUES and is Invalid Please enter a value for the knapsack (q to Quit): 1 Please enter a value for the knapsack (q to Quit): 4 Please enter a value for the knapsack (q to Quit): 6 Please enter a value for the knapsack (q to Quit): 12 Please enter a value for the knapsack (q to Quit): 28 Please enter a value for the knapsack (q to Quit): q Verifying Knapsack: 1, 4, 6, 12, 28 Knapsack is Simple Super Increasing! 

Refer to the example above, ensure your spacing matches the example perfectly.

Submit a document containing a screen shot of your code in its .py file along with a screenshot of the output.

Submit your .py file as well.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!