Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started