create a python script using the requirements and explain how it functions, please. I have added my starter code to work from as well as my desired outcome in the examples below. I attached my stater code in a screenshot as it was too long to include in my question for this exercise.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question

create a python script using the requirements and explain how it functions, please. I have added my starter code to work from as well as my desired outcome in the examples below. I attached my stater code in a screenshot as it was too long to include in my question for this exercise.

you will complete a program that keeps track of the inventory of items a wizard is carrying. Your program will allow the user to show/add/remove/modify the items the wizard is carrying.

You are given a partially written code for this program;
your job is to write 4 functions that implement response to user commands. Read and understand the existing code –it has implemented the functions that handle printing welcome messages and the rules, and also the main function that handles the command loop. You are supposed to implement four functions -show, grab_item, drop_item, edit_item-that accept two lists: a list containing the names of the items and the other containing the weights of the items. The main function initializes the names list with 3 items “wooden staff”, “wizard hat”, “cloth shoes” and the weights list with weights of those items as 30.0, 1.5, 5.3 lbs respectively.
Here's what each function that you are implementing is supposed to do:
1.show: Lists the items that the wizard is currently carrying along with the index for each item and the weight of that item. See sample runs below. As shown in the sample this function also prints the total weight of the items along with the max weight limit of 100 lbs.Hint: You can use the sum function in Python to calculate the sum of weights. E.g. sum(weights) will return the sum of all the items in the weights list.
2.grab_item: Add a new itemwhile enforcing the following policy: There is a limit of 4 on the number of items the wizard can carryand a limit of 100 lbs on the total weightthe wizard can carry. So specifically, if the wizard is already carrying 4 items, print message that “You can't carry anymore items. Drop something first.”And return out of the function. Otherwise prompt the user for the name and the weight of the new item. Next check whether with the addition of the new item,the total weight will exceed the limit of 100 lbs. If so, print a message saying the weight limit will be exceeded, so cannot add the new item and return it out of the function. Otherwise, add the new name and weight to the two lists. See Sample runs below. Hint: You can use the sum function in Python to calculate the sum of weights. E.g. sum(weights) will return the sum of all the items in the weights list.
3.edit_item: Allow the user to update (only) the name of one of the items. Prompt the user for the index of the item to be edited. Validate that the index is between 1 and the current count of items.If invalid, print a message to that effect and exit. Otherwise prompt the user for the new name and update the name of the item. Print that the item was updated successfully. See Sample runs below.
4.drop_item: Prompt the user for the index of the item to be dropped. Validate that the index is between 1 and the current count of items. Remove the item from both lists. Print that the item was removed successfully. See Sample runs below.Read the description above and the sample runs shown below closely to understand what each command does. Add useful comments throughout the code.
 
 
### Wizard Inventory Program

The following is a Python program designed to keep track of the inventory items a wizard is carrying. It allows users to show, add, remove, and edit the items in the wizard's inventory, while ensuring that the weight and count limits are respected.

#### Constants:
- `WEIGHT_LIMIT = 100`
- `COUNT_LIMIT = 4`

#### Functions:

1. **display_title():**
   ```python
   def display_title():
       print("The Wizard Inventory program")
       print()
   ```

2. **display_menu():**
   ```python
   def display_menu():
       print("COMMAND MENU")
       print("show - Show all items")
       print("grab - Grab an item")
       print("edit - Edit an item")
       print("drop - Drop an item")
       print("exit - Exit program")
       print()
   ```
   
3. **show(names, weights):**
   ```python
   def show(names, weights):
       '''
       Function to show the items listed in names and weights list in the form: index name (weight lbs).
       At the end print the current total weight of the items and the weight limit of 100 lbs.
       '''
       # To be implemented
       pass
   ```

4. **grab_item(names, weights):**
   ```python
   def grab_item(names, weights):
       '''
       Function to add an item to the items list. Check if the lists already have 4 items, then print a message 
       saying cannot add more and exit. Otherwise prompt the user for the name and the weight of the new item.
       Check if with the addition of the new item the weight limit of 100 lbs will be exceeded. If so, print a 
       message saying weight limit will be exceeded, cannot add and exit. Add the new name and weight to the two lists.
       '''
       # To be implemented
       pass
   ```

5. **edit_item(names, weights):**
   ```python
   def edit_item(names, weights):
       '''
       Function to edit name of an item from the two lists. Prompt the user for the index of the item to be edited.
       Validate that the index is between 1 and count of items. If invalid index, print a message saying the index 
       is invalid. Else, prompt the user for the new name and update the name of the correct item.
       '''
       # To
Transcribed Image Text:### Wizard Inventory Program The following is a Python program designed to keep track of the inventory items a wizard is carrying. It allows users to show, add, remove, and edit the items in the wizard's inventory, while ensuring that the weight and count limits are respected. #### Constants: - `WEIGHT_LIMIT = 100` - `COUNT_LIMIT = 4` #### Functions: 1. **display_title():** ```python def display_title(): print("The Wizard Inventory program") print() ``` 2. **display_menu():** ```python def display_menu(): print("COMMAND MENU") print("show - Show all items") print("grab - Grab an item") print("edit - Edit an item") print("drop - Drop an item") print("exit - Exit program") print() ``` 3. **show(names, weights):** ```python def show(names, weights): ''' Function to show the items listed in names and weights list in the form: index name (weight lbs). At the end print the current total weight of the items and the weight limit of 100 lbs. ''' # To be implemented pass ``` 4. **grab_item(names, weights):** ```python def grab_item(names, weights): ''' Function to add an item to the items list. Check if the lists already have 4 items, then print a message saying cannot add more and exit. Otherwise prompt the user for the name and the weight of the new item. Check if with the addition of the new item the weight limit of 100 lbs will be exceeded. If so, print a message saying weight limit will be exceeded, cannot add and exit. Add the new name and weight to the two lists. ''' # To be implemented pass ``` 5. **edit_item(names, weights):** ```python def edit_item(names, weights): ''' Function to edit name of an item from the two lists. Prompt the user for the index of the item to be edited. Validate that the index is between 1 and count of items. If invalid index, print a message saying the index is invalid. Else, prompt the user for the new name and update the name of the correct item. ''' # To
### Sample Run 1: show/grab/edit/drop

#### The Wizard Inventory Program

This program allows users to manage an inventory of magical items with various commands. Below is a detailed example of how to use the program effectively.

#### COMMAND MENU

- **show** - Display all items in the inventory
- **grab** - Add a new item to the inventory
- **edit** - Modify an existing item in the inventory
- **drop** - Remove an item from the inventory
- **exit** - Exit the program

#### Example Commands and Output

**Command: show**
```plaintext
1. wooden staff ( 30.0 lbs )
2. wizard hat ( 1.5 lbs )
3. cloth shoes ( 5.3 lbs )
```
**Total Weight: 36.8 lbs  Weight Limit: 100 lbs**

**Command: grab**
```plaintext
Name: Wand
Weight in lbs: 3
```
**Output:**
```plaintext
Wand ( 3.0 lbs ) was added.
```

**Command: show**
```plaintext
1. wooden staff ( 30.0 lbs )
2. wizard hat ( 1.5 lbs )
3. cloth shoes ( 5.3 lbs )
4. Wand ( 3.0 lbs )
```
**Total Weight: 39.8 lbs  Weight Limit: 100 lbs**

**Command: grab**
```plaintext
You can't carry any more items. Drop something first.
```

**Command: drop**
```plaintext
Number: 2
```
**Output:**
```plaintext
wizard hat ( 1.5 lbs ) was dropped.
```

**Command: edit**
```plaintext
Number: 3
Enter updated name: Most Powerful Wand
```
**Output:**
```plaintext
Item number 3 was updated.
```

**Command: show**
```plaintext
1. wooden staff ( 30.0 lbs )
2. cloth shoes ( 5.3 lbs )
3. Most Powerful Wand ( 3.0 lbs )
```
**Total Weight: 38.3 lbs  Weight Limit: 100 lbs**

By following the steps above, users can manage their inventory efficiently, ensuring they do not exceed the weight limit while updating the names of items as needed.
Transcribed Image Text:### Sample Run 1: show/grab/edit/drop #### The Wizard Inventory Program This program allows users to manage an inventory of magical items with various commands. Below is a detailed example of how to use the program effectively. #### COMMAND MENU - **show** - Display all items in the inventory - **grab** - Add a new item to the inventory - **edit** - Modify an existing item in the inventory - **drop** - Remove an item from the inventory - **exit** - Exit the program #### Example Commands and Output **Command: show** ```plaintext 1. wooden staff ( 30.0 lbs ) 2. wizard hat ( 1.5 lbs ) 3. cloth shoes ( 5.3 lbs ) ``` **Total Weight: 36.8 lbs Weight Limit: 100 lbs** **Command: grab** ```plaintext Name: Wand Weight in lbs: 3 ``` **Output:** ```plaintext Wand ( 3.0 lbs ) was added. ``` **Command: show** ```plaintext 1. wooden staff ( 30.0 lbs ) 2. wizard hat ( 1.5 lbs ) 3. cloth shoes ( 5.3 lbs ) 4. Wand ( 3.0 lbs ) ``` **Total Weight: 39.8 lbs Weight Limit: 100 lbs** **Command: grab** ```plaintext You can't carry any more items. Drop something first. ``` **Command: drop** ```plaintext Number: 2 ``` **Output:** ```plaintext wizard hat ( 1.5 lbs ) was dropped. ``` **Command: edit** ```plaintext Number: 3 Enter updated name: Most Powerful Wand ``` **Output:** ```plaintext Item number 3 was updated. ``` **Command: show** ```plaintext 1. wooden staff ( 30.0 lbs ) 2. cloth shoes ( 5.3 lbs ) 3. Most Powerful Wand ( 3.0 lbs ) ``` **Total Weight: 38.3 lbs Weight Limit: 100 lbs** By following the steps above, users can manage their inventory efficiently, ensuring they do not exceed the weight limit while updating the names of items as needed.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education